Menu DEVPPL Search
160.588
MEMBERS
15.941
TOPICS
63.227
POSTS
  562
FLASH GAMES
7.717
TUTORIALS
 

Login

E-mail:
Password:

Can anyone help me?? using scanner stdin??

0

Loading

Can anyone help me?? using scanner stdin??

Postby Shadachi » Tue Jul 03, 2007 12:10 pm

This is the question?.. can anyone help me?? kinda confused..

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 :

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..


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);





}
}
Shadachi
 
Reputation: 0
Posts: 7
Joined: Fri May 18, 2007 7:05 am
Highscores: 0
Arcade winning challenges: 0

Can anyone help me?? using scanner stdin?? - Sponsored results

Sponsored results

Login to get rid of ads

 

^ Back to Top