File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes The problem again.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

The problem again....

Thomas Wren

Joined: Nov 06, 2006
Posts: 11
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


Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

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.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: The problem again....
It's not a secret anymore!