This is the question?.. can anyone help me?? kinda confused..using JcreatorLe
SAmple Output :
I kinda messed up alot..
here is my codes..
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
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.Decim alFormat;
import java.lang.Doubl e;
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.prin t("Is there an order to process? (Y?N)");
Result= stdin.next();
do
{
System.out.prin t("Enter the price for book %d: RM ");
price = stdin.nextDoubl e();
System.out.prin t("Enter the quantity for book %d: ");
quantity = stdin.nextInt() ;
quantity1 = quantity1 + quantity;
cost = (double)((price * quantity) * 1.075);
System.out.prin tln("Cost for book %d: %.2lf \n");
sum1 = sum + cost;
count++;
System.out.prin t("Is there an order to process? (Y?N)");
}while ((Result =='y'));
System.out.prin tln("\nTotal number of orders processed:%d "+count);
System.out.prin tln("\nTotal number of books sold:%d "+quantity1 );
System.out.prin tln("\nTotal price:%.2lf \n"+sum1);
}
}
import java.text.Decim alFormat;
import java.lang.Doubl e;
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.prin t("Is there an order to process? (Y?N)");
Result= stdin.next();
do
{
System.out.prin t("Enter the price for book %d: RM ");
price = stdin.nextDoubl e();
System.out.prin t("Enter the quantity for book %d: ");
quantity = stdin.nextInt() ;
quantity1 = quantity1 + quantity;
cost = (double)((price * quantity) * 1.075);
System.out.prin tln("Cost for book %d: %.2lf \n");
sum1 = sum + cost;
count++;
System.out.prin t("Is there an order to process? (Y?N)");
}while ((Result =='y'));
System.out.prin tln("\nTotal number of orders processed:%d "+count);
System.out.prin tln("\nTotal number of books sold:%d "+quantity1 );
System.out.prin tln("\nTotal price:%.2lf \n"+sum1);
}
}
Comment