The Artima Developer Community
Sponsored Link

Java Answers Forum
pseduo code help

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
sherri statham

Posts: 2
Nickname: iwlu10101
Registered: Sep, 2006

pseduo code help Posted: Sep 28, 2006 9:50 AM
Reply to this message Reply
Advertisement
Well I have this program to develope from this code, Yes I know yuk!!!
Can anyone point me or lead me in the right direction, because I dont think what I have so far is right or close>


MailOrder

+main(args [ ] : String)

-PrintSalesReport( quantitySoldOfProduct1: int,

quantitySoldOfProduct2: int,

quantitySoldOfProduct3: int,

quantitySoldOfProduct4: int,

quantitySoldOfProduct5: int)





DEFINE a local variable input, a Scanner

DEFINE a local variable quantitySoldOfProduct1, an integer and initialize it to zero

DEFINE a local variable quantitySoldOfProduct2, an integer and initialize it to zero

DEFINE a local variable quantitySoldOfProduct3, an integer and initialize it to zero

DEFINE a local variable quantitySoldOfProduct4, an integer and initialize it to zero

DEFINE a local variable quantitySoldOfProduct5, an integer and initialize it to zero

DEFINE a local variable productId, an integer

DEFINE a local variable quantitySoldOfProduct, an integer

DISPLAY a blank line followed by the task id and programmer (your name) identification line.

DISPLAY a blank line followed by the “Program input:” line

DISPLAY the initial “Enter product number…” prompt

DO

Using nextInt() method of input variable, ASSIGN the entered value to productId

Using printf() method and appropriate horizontal tab(s), DISPLAY “Quantity sold” prompt

Using nextInt() method of input variable, ASSIGN the enter value to quantitySoldOfProduct

the switch statement, summarize quantitySoldOfProduct into appropriate

quantitySoldOfProduct1 through quantitySoldOfProduct5, depending on value of productId.

Within the switch statement, using default case, if an invalid productId has been entered,

DISPLAY an appropriate error message and ignore the input

DISPLAY the “Enter product…” prompt

WHILE (input.hasNext())

Using PrintSalesReport() method, print the sales report

DISPLAY a blank line followed by the “End of Program” line

DEFINE a local variable totalSalesAllProducts, an double and initialize it to zero

DEFINE a local variable unitPriceOfProduct1, an double and initialize it to 2.98

DEFINE a local variable unitPriceOfProduct2, an double and initialize it to 4.50

DEFINE a local variable unitPriceOfProduct3, an double and initialize it to 9.98

DEFINE a local variable unitPriceOfProduct4, an double and initialize it to 4.49

DEFINE a local variable unitPriceOfProduct5, an double and initialize it to 6.87

DEFINE a local variable product1Sales, a double and initialize it to

quantitySoldOfProduct1 * unitPriceOfProduct1

DEFINE a local variable product2Sales, a double and initialize it to

quantitySoldOfProduct2 * unitPriceOfProduct2

DEFINE a local variable product3Sales, a double and initialize it to

quantitySoldOfProduct3 * unitPriceOfProduct3

DEFINE a local variable product4Sales, a double and initialize it to

quantitySoldOfProduct4 * unitPriceOfProduct4

DEFINE a local variable product5Sales, a double and initialize it to

quantitySoldOfProduct5 * unitPriceOfProduct5

DISPLAY a blank line followed by the “Program output:” line

Using appropriate format specifiers and horizontal tabs, DISPLAY the column heading line

followed by a blank line

Using appropriate format specifiers and horizontal tabs, DISPLAY one line for each

product, its quantity sold, its unit price and its total sales

ASSIGN the sum of product1Sales through product5Sales TO totalSalesAllProducts

Using appropriate format specifiers and horizontal tabs, DISPLAY the “Total Sales” line


import java.util.Scanner;
 
public class MailOrder
{
    public static void main(String[] args)
    {
    Scanner input = new Scanner( System.in );
 
    int quantitySoldOfProduct1 = 0;
    int quantitySoldOfProduct2 = 0;
    int quantitySoldOfProduct3 = 0;
    int quantitySoldOfProduct4 = 0;
    int quantitySoldOfProduct5 = 0;
    int productId;
    int quantitySoldOfProduct;
    
    System.out.println("\nTask 07-02, Ch05,   Programmed by");
    
    System.out.println("\nProgram input:");
    
    System.out.print( "Enter product number, or (<ctrl>z to stop): ");
    productId = input.nextInt();
    
    
    
 
 
    int totalSalesAllProducts = 0;
    int unitPriceOfProduct1 = 2.98; 
    int unitPriceOfProduct2 = 4.50;  
    int unitPriceOfProduct3 = 9.98; 
    int unitPriceOfProduct4 = 4.49; 
    int unitPriceOfProduct5 = 6.87; 
    double product1Sales = quantitySoldOfProduct1*unitPriceOfProduct1;
    double product2Sales = quantitySoldOfProduct2*unitPriceOfProduct2;
    double product3Sales = quantitySoldOfProduct3*unitPriceOfProduct3;
    double product4Sales = quantitySoldOfProduct4*unitPriceOfProduct4;
    double product5Sales = quantitySoldOfProduct5*unitPriceOfProduct5;
    
    System.out.println("\nProgram output:");
    
    
 
 
 
 
 
 
    } // end method processSalesResults
} // end class Sales
 

Topic: Best way to learn JAVA basics Previous Topic   Next Topic Topic: Java: switch and

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use