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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The problem again....

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic