Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

The problem again....

 
Thomas Wren
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hey, Guys and gals..


I am facing a problem with a problem. My problem is I do not know how to start this problem. The problem is:


A mail-order house sells five products whose retail prices are as follows: Product 1, $2.98; product 2, $4.50; product 3, %9.98; product 4, $4.49 and product 5, $6.87. Write an application that reads a seris of pairs of numbers as follows:
a) product number b)quantity sold

The program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.

The program should have two methods. Not counting the main.


I have made a switch Statement. I know need to get a result. How do i do that. Here is the Switch Code:
import java.util.Scanner; // program uses Scanner

public class tw54663A8def

{

private int total;
private int aCount;
private int bCount;
private int cCount;
private int dCount;

public static void prodCounters( int prodN, int prodQ)

{
switch ( prodN )

{

case 1: ++ prodQ; // increment aCount
break; // neccessary to exit switch statement

case 2: ++ prodQ; // increment bCount
break; // necessary to exit switch statement

case 3: ++ prodQ; // increment cCount
break; // necessary to exit switch statement

case 4: ++ prodQ; // increment dCount
break; // necessary to exit switch statement

default: ++ prodQ; // increment default
break; // necessary to exit switch statement

}
}

Thanks,
Thomas
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question repeatedly; you'll just get people rehashing the discussion that has already taken place. I'm closing this thread; the interested reader is directed to the original thread.
 
    Bookmark Topic Watch Topic
  • New Topic