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

  Create a circle class

create acircle class, which has one field, the radius. the class should contains two constructors: a no-argument constructor that set the radius to zero, and a constructor that takes a parameter to set the radius.

  Write an interface for a bagadt that implements iterable

Write an interface for a BagADT that implements the Iterable interface. Include javadoc comments that will generate specifications for the BagADT so that someone who wants to implement this interface will know what each method does.

  Identify the 5 code elements

Identify the 5 code elements for a Password class. Things like: class, instance, and final variables, accessor and mutator method, public and private specifiers for methods and member variables.i need to provide detail and descriptions for each code ..

  Communication with an smtp server

Develop a graphical user interface based java program that can communicate with a real SMTP email server for sending emails

  Implementation activities of software development

Analysis, design, and implementation activities of software development

  Design a program to help a videorental store

Design classes (class video, class customer, etc) based on your analysis above, using LINKED LISTS for the database elements read into the main memory.

  Give at least one constructor without any parameter

We learned as popular Set implementation. Write own TreeSet class that implements following interface: You are to give at least one constructor without any parameter.

  Pass in the number of gallons on board

public float usefulLoad() // this is the grossWeight - emptyWeight public float usefulLoadWithFuel( in gallons ) // this is the useful load - gallons x 6. The programmer user will pass in the number of gallons on board.

  Java program use breadth-first search closest broadcast

Write the java program which will use breadth-first search (which you implement as part of your program) to determine the closest broadcast vertex for each vertex in graph.

  Write the method in java

2.char mostOftenIn(String s) that for a given string s, returns the character that occurs most often in s.

  The ai player will not be asking

The AI player will not be asking the user for any input. This means that placeShips() and fire() should not ask the user for locations. The AI player should choose locations of ships and automatically place them

  Create a file that contains your favorite movie quote

Create a file that contains your favorite movie quote. Use a text editor such as Notepad, and save the file as quote.txt. Copy the file contents,

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