Write a complete program which computes the sum

Assignment Help JAVA Programming
Reference no: EM13166571

Write a complete program (actually complete the one on the exam) which computes the following sum: ( 100 / 1 ) + ( 99 / 2 ) + ( 98 / 3 ) + ( 97 / 4 ) + ... + ( 3 / 98 ) + ( 2 / 99 ) + ( 1 / 100 ) Use a FOR loop in your program (where indicated) to compute the answer. Display the result with 3 decimal places. Hint: Use printf not println.

Here's what I have right now and I can't find out what's wrong with it?

import java.util.Scanner;

public class oneontheexam {
  
   public static void main(String [] args) {
  
   double sum = 0;
  
   for (int i = 1; i<=100; i++)
   sum += (100.0 - i + 1) / 1;
  
   }
}

Reference no: EM13166571

Questions Cloud

Since mac address is unique for each device : Since MAC address is unique for each device, why Internet does not use MAC address for routing and communications, instead, they assign an IP address to each machine? Here we do not count that MAC address is longer than IPv4 address (since IPv6 ha..
Assume a gpu architecture that contains 10 simd : Assume a GPU architecture that contains 10 SIMD processors. Each SIMD instruction has a width of 32 and each SIMD processor contains 8 lanes for single-precision arithmetic and load/store instructions, meaning that each non- diverged SIMD instruct..
Random permutations : Write a program in C++ that gives a prompt to the users, asking for an integer M.It then prints out a M different random permutations, one on each of M lines, of the numbers 1, 2, ... , 10, separated by spaces or tabs.
Eiffel tower ridiculous eyesore : Explain whether you agree with the opinion of many Parisians in 1889 that the Eiffel Tower was a ridiculous eyesore that should have been torn down after the World’s Fair.
Write a complete program which computes the sum : Write a complete program (actually complete the one on the exam) which computes the following sum: ( 100 / 1 ) + ( 99 / 2 ) + ( 98 / 3 ) + ( 97 / 4 ) + ... + ( 3 / 98 ) + ( 2 / 99 ) + ( 1 / 100 ) Use a FOR loop in your program (where indicated) to..
Cuckoo hashing : Using Cuckoo hashing, hash the following keys using the (h1,h2) pairs shown. A: 2,0 B: 0,0 C: 4,1 D: 0,1 E: 2,3 Using Hopscotch hashing with a max hop of 4, hash the following keys. A: 6 B: 7 C: 9 D: 7 E: 6 F: 7 G: 8
Hash values : Suppose these names have the following hash values. Insert them into the extendible hash table shown below. Each leaf can only hold 4 entries.
Comparitive advantages of capitalism and socialism : Given the discussion of the comparitive advantages of capitalism and socialism, consider what the U.S. might gain and lose by moving toward a democratic socialist system..200-300 words refercences, no abstract or cover.. Intro to Sociology
Open addressing with double hashing where second hash funcn : Given the input {3810, 8832, 8653, 2863, 3580, 8440, 1941, 4290, 8805, 7400}

Reviews

Write a Review

JAVA Programming Questions & Answers

  Give an implementation of the queue adt using an array

Give an implementation of the Deque ADT using an array, so that each of the update methods run in O(1) time. Program has to be written in Java.

  Create a web application for sheridan restaurant

Create a web application for Sheridan Restaurant Reviews that contains the following functionality - Display a table of all restaurants based on the city entered by the user

  Determine the type of moped

Write a driver class called MopedRental. This class should perform the following: asks the user to enter the size of the moped, the day of the week and the number of hours rented, creates the Moped object, based on the size, and displays the input..

  Create listener objects for each jcombobox

Create listener objects for each JComboBox that set the background color of the panel when the user selects an integer. Use the current values supplied by the JComboBox objects to determine the background color.

  Alter the prototype form page by javascript function

Alter the prototype form page so that when JavaScript function has verified that all the required fields have been filled, cookie is added to user's computer.

  What makes a program easy to modify

Describe the order of magnitude of the code section using Big(O) notation and Explain the relationship between dynamic storage allocation and recursion.

  Design a program that extends the definition of the class

Design a program that extends the definition of the class JFrame to display a window on the screen. Name your class PropertyTax1, title your window "Calculation of Property Taxes," set the window's width to 400 pixels and height to 300 pixels, and te..

  Java :a user-defined starting position (other than 0,0)

modifying the program so that it can start from a user-defined starting position (other than 0,0) and search for a user defined ending point (other than row-1, column-1) .

  Reverse the array, and find the largest element

find the max block of an array by splitting it into three parts: left, middle, right. And then reverse the array, and find the largest element.

  Length of the string in order to reserve space

To determine the length of the string in order to reserve space for the new string use the library routine strlen. Register a1 contains a pointer to the string to measure and on return register a1 has the number of characters in the string. You..

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Implement an intrusion detection system in java

You are to implement an intrusion detection system in java. Calculate a threshold for detecting an intrusion. The threshold is 2*(Sums of weights).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd