469,890 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

interactive java program

CODE]
the project is to ask the user to enter three nonnegative intergers to
represent a time amount measured in hours, minutes, and seconds and then prints the equivalent time in seconds. Use three lines for input and one linf for output. The user's responsers should be on the same line as the prompts. One the output line use a complete and corret sentence that echoes the input and shows the equivalent total time in seconds.CODE]

[
Expand|Select|Wrap|Line Numbers
  1. B]the total time in seconds.[/Output should be exactly like this:
  2. The time interval 0 hours hours (s), 1 minute (s), and 0 seconds (s) is equivalent to 60 second (s).[/b]
Expand|Select|Wrap|Line Numbers
  1. Have input any special input situtations
Expand|Select|Wrap|Line Numbers
  1. Design the program with separate sections for input, annalysis, and output; use variables to hold the number of hours, minutes, and seconds.
Expand|Select|Wrap|Line Numbers
  1. Includeprint outs of at least 11 trial runs. Donot overlook extreme, marginal, and special cases of input. What happens if it crashes?
  2.  
  3. My instructor sugged we write & run a preliminary on an easy topic, here is mine but I am having trouble revising iit.
  4.  
  5. Please help!

Here is mine start:Please me get it into the type of program that is required. Thx!

//DivisionTester.java
//Purpose: This is an interactive program to test how interger division works.
import java.util.scanner;

public class DivisionTester
{
//
public static void main (String [] args)

{
//need a comment for main method

int numerator; // the user's numerator for the division
int denominator;// the user's denominator for the division
int quotient; // the calculated quotient of the two input values
scanner scan = newScanner(System.in);

//get the input values
system.out.print("Enter the numerator (as integer); ");
numerator = scan.nextInt();

system.out.print("Enter the denominator (as a nonzero number); ");
denominator = scan.nextInt();;

//calculate the quotient
quotient = r;

//report the quotient

system.out.println(numerator + "/" + denominator + " = ' + quotient);

} // end of main method
}// end of DivisionTester class
Oct 3 '06 #1
1 2580
r035198x
13,262 8TB
CODE] represent a time amount measured in hours, minutes, and seconds and then prints the equivalent time in seconds. Use three lines for input and one linf for output. The user's responsers should be on the same line as the prompts. One the output line use a complete and corret sentence that echoes the input and shows the equivalent total time in seconds.CODE]

[
Expand|Select|Wrap|Line Numbers
  1. B]the total time in seconds.[/Output should be exactly like this:
  2. The time interval 0 hours hours (s), 1 minute (s), and 0 seconds (s) is equivalent to 60 second (s).[/b]
Expand|Select|Wrap|Line Numbers
  1. Have input any special input situtations
Expand|Select|Wrap|Line Numbers
  1. Design the program with separate sections for input, annalysis, and output; use variables to hold the number of hours, minutes, and seconds.
Expand|Select|Wrap|Line Numbers
  1. Includeprint outs of at least 11 trial runs. Donot overlook extreme, marginal, and special cases of input. What happens if it crashes?
  2.  
  3. My instructor sugged we write & run a preliminary on an easy topic, here is mine but I am having trouble revising iit.
  4.  
  5. Please help!

Here is mine start:Please me get it into the type of program that is required. Thx!

//DivisionTester.java
//Purpose: This is an interactive program to test how interger division works.
import java.util.scanner;

public class DivisionTester
{
//
public static void main (String [] args)

{
//need a comment for main method

int numerator; // the user's numerator for the division
int denominator;// the user's denominator for the division
int quotient; // the calculated quotient of the two input values
scanner scan = newScanner(System.in);

//get the input values
system.out.print("Enter the numerator (as integer); ");
numerator = scan.nextInt();

system.out.print("Enter the denominator (as a nonzero number); ");
denominator = scan.nextInt();;

//calculate the quotient
quotient = r;

//report the quotient

system.out.println(numerator + "/" + denominator + " = ' + quotient);

} // end of main method
}// end of DivisionTester class
1. Use code tags for posting code.
2. Do not use code tags for text that is not code
3. Java is case sensitive scanner != Scanner, system != System etc.
4. Variables have to be declared before they are used, thus quotient = r; will not compile
5. Division produces non integral results. Use double not int to represent the quotient.
Expand|Select|Wrap|Line Numbers
  1. double r = numerator / (double)denominator;
6. Please make these corrections and post if have further problems
Oct 3 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

147 posts views Thread by Sateesh | last post: by
20 posts views Thread by Joe | last post: by
5 posts views Thread by Eckhoff, Michael A | last post: by
22 posts views Thread by SeeBelow | last post: by
2 posts views Thread by Allan Adler | last post: by
10 posts views Thread by notejam | last post: by
3 posts views Thread by R. Bernstein | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.