Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

The problem again....  RSS feed

 
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
 
author and iconoclast
Posts: 24203
43
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.
 
I'm so happy! And I wish to make this tiny ad happy too:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!