Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 9:13 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ]  Bookmark and Share
Author Message
 Post subject: Can anyone help me?? using scanner stdin??
PostPosted: Tue Jul 03, 2007 12:10 pm 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
This is the question?.. can anyone help me?? kinda confused..

Quote:
A wholesale book dealer needs a program to write invoices for book orders that he takes for a customer over the phone. Each order usually consists of multiple copies of several book titles. The program should ask the user if there is an order to process. If the user responses yes, then the program should ask for the price of the first book in the order and the number of such books. The program should then display the cost of these books, including a 7.5% sales tax. Then the program should ask if there is another order. If there is one, the program should process it as just described. If there are no more orders, the program should display the total number of orders processed, the total number of books sold, and the total receipts.



SAmple Output :

Quote:
Is there an order to process (Y/N)? y

Enter the price for book 1: RM 20.00
Enter the quantity for book 1: 3
Cost for book 1: RM64.50

Is there an order to process (Y/N)? y

Enter the price for book 2: RM 50.00
Enter the quantity for book 2: 2
Cost for book 2: RM 107.50

Is there an order to process (Y/N)? y

Enter the price for book 3: RM 40.00
Enter the quantity for book 3: 2
Cost for book 3: RM 86.00

Is there an order to process (Y/N)? y

Enter the price for book 4: RM 10.00
Enter the quantity for book 4: 3
Cost for book 4: RM 32.25

Is there an order to process (Y/N)? n

Total number of orders processed: 4
Total number of books sold: 10
Total price: RM 290.25



I kinda messed up alot..
here is my codes..


Quote:
import java.util.*;
import java.text.DecimalFormat;
import java.lang.Double;


public class Book {



public static void main(String args[]){

int process;
double price;
int quantity;
int quantity1=0;
double sum=0.00;
double sum1=0.00;
double cost=0.00;
String Result="";


DecimalFormat twoDigits = new DecimalFormat("0.00");
Scanner stdin= new Scanner(System.in);


System.out.print("Is there an order to process? (Y?N)");

Result= stdin.next();


do

{
System.out.print("Enter the price for book %d: RM ");

price = stdin.nextDouble();

System.out.print("Enter the quantity for book %d: ");

quantity = stdin.nextInt();


quantity1 = quantity1 + quantity;

cost = (double)((price * quantity) * 1.075);

System.out.println("Cost for book %d: %.2lf \n");

sum1 = sum + cost;
count++;

System.out.print("Is there an order to process? (Y?N)");


}while ((Result =='y'));

System.out.println("\nTotal number of orders processed:%d "+count);
System.out.println("\nTotal number of books sold:%d "+quantity1);
System.out.println("\nTotal price:%.2lf \n"+sum1);





}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley