interactive java program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • recioss
    New Member
    • Oct 2006
    • 1

    #1

    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]

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

    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.scann er;

    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(Syst em.in);

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

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

    //calculate the quotient
    quotient = r;

    //report the quotient

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

    } // end of main method
    }// end of DivisionTester class
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by recioss
    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]

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

    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.scann er;

    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(Syst em.in);

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

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

    //calculate the quotient
    quotient = r;

    //report the quotient

    system.out.prin tln(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.
    Code:
    double r = numerator / (double)denominator;
    6. Please make these corrections and post if have further problems

    Comment

    Working...