View Single Post
Newbie Member
23Sep2011,11:04  
Diana72's Avatar
example output:-
Order quantity 154kg
100kg Sacks 1
20kg Sacks 2
10kg Sacks 1
Total number of sacks : 4kg
Invoice : $21.90


i tried case A, and its not working T__T anyway here my answer
Code:
import java.util.*; 

public class orangePte { 
public static void main(String[]args){ 

String retailer_name; 
int retailer_code; 
int quantity_order; 
int short_order = 0; 
int total_no_sacks; 
char order_code; 

Scanner input = new Scanner(System.in); 

System.out.print("please enter retailer name :"); 
retailer_name = input.next(); 

System.out.print("please enter retailer code :"); 
retailer_code = input.nextInt(); 

System.out.print("please enter quantity order :"); 
quantity_order = input.nextInt(); 

System.out.print("order code, code)" + "A or a ()," + "B or b ()," + "C or c()," + "D or d() :"); 
order_code = input.next().charAt(0); 

switch (order_code) { 
case 'A': case 'a': 

if (quantity_order < 100 & quantity_order>20){ 
quantity_order = quantity_order/20; 
short_order = quantity_order%20; 
} 

if (quantity_order < 20 & quantity_order>10){ 
quantity_order = quantity_order/10; 
short_order = quantity_order%10; 
} 

if(quantity_order <10 & quantity_order>5){ 
quantity_order = quantity_order/5; 
short_order = quantity_order%5; 
} 

//Display quantity order, short order; 
System.out.println("quantity order : " + quantity_order); 
System.out.println("short order :" + short_order); 



} 
} 

}

Last edited by shabbir; 23Sep2011 at 11:33.. Reason: Code blocks