Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Sat Nov 21, 2009 10:11 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ]  Bookmark and Share
Author Message
 Post subject: Anyone can help me ?? i dono how to start??
PostPosted: Fri May 18, 2007 7:13 am 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
Question 1

The mail-order company requires a program to calculate discounts that it is giving to all its customers during a sales campaign. Write a program that asks the user to enter the total price of an order. If the order price is RM200.00 or less, the discount rate is 10%. If the order price is greater than RM200.00, the discount rate is 15%.The net price of the order is the price minus the discount. The program should display the price of the order, the discount amount, and the net price of the order. Design the program to process any number of orders. When there are no more orders to process, the program should display the number of orders it processed, the total of the prices, the total of the discounts, and the total of the net prices.



Sample output...

Enter the total price of an order: $150.50

Order price: $150.50
Discount amount: $15.05
Net order price: $135.45

Do you have any other orders to proceed? (y/n) : y

Enter the total price of an order: $420.30

Order price: $420.30
Discount amount: $63.05
Net order price: $357.25

Do you have any other orders to proceed? (y/n) : y

Enter the total price of an order: $200.00

Order price: $200.00
Discount amount: $20.00
Net order price: $180.00

Do you have any other orders to proceed? (y/n) : n

Total number of orders: 3
Total order prices: $770.80
Total discounts: $98.10
Total net prices: $672.70


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 20, 2007 6:26 am 
Offline

Joined: Wed Apr 18, 2007 3:25 am
Posts: 7
Heres what I can up with in the short amount of time I have. Please remember I'm still learning, but what I put here should give you an idea of what you need to do. Also, I will leave basic stuff out that you should know by now:


Code:

double order_price;
String more_purchases = "";
int num_of_orders = 0;
double total_orders = 0;
double net_price = 0;
double tota_price = 0;
double total_net = 0;
double total_disc = 0;
double discount_amt;

System.out.println("Enter the total price of an order: ");
order_price = keyboard.nextDouble();

while(more_purchases.equals(y))
{
   if(order_price <= 200.00)
   {
      System.out.println("Order price: " + order_price);
      total_price += order_price;
      total_orders++;
      
      discount_amt = order_price * .1;
      System.out.println("Discount amount: " + discount_amt);
      total_disc += discount_amt;
      
      net_price = order_price - discount_amt;
      System.out.println("Net order price: " + net_price);
      total_net += net_price;
   }
   
   System.out.print("\n");
   
   System.out.print("Do you have any other orders to proceed? (y/n): ")
   more_purchases = keyboard.next();
}

System.out.print("\n");

System.out.println("Total number of orders: " + total_orders);
System.out.println("Total order prices: " + total_price);
System.out.println("Total discounts: " + total_disc);
System.out.println("Total net prices: " + total_net);



This should take care of one of the discounts. Good luck with the rest of your project.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 20, 2007 2:21 pm 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
i see.. now trying to implement it..but i am not that certain ><


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 20, 2007 6:41 pm 
Offline

Joined: Wed Apr 18, 2007 3:25 am
Posts: 7
You pretty much have to set another condition or 2 within the while loop. oh and I forgot to make it so it ask you to enter another order price. Its pretty much the exact same thing, but under a different condition. Good luck.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 20, 2007 7:07 pm 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
i am currently using JCreator..

i came out wit these codes..>< can help add or correct?? i cant reli understand the while loop yet.

Quote:
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
public class Discount {

public static void main (String args []){



int DisCheap;
int DisExp ;
Double total ;
Double pricey;

String Input;
String output ;


DisCheap = 10;
DisExp = 15;


Input = JOptionPane.showInputDialog("Enter the price plz");

pricey = Double.parseDouble(Input);




DecimalFormat twoDigits = new DecimalFormat("0.00");



if (pricey <= 200.00){
total = (double)pricey / 100*DisCheap;


output = "Order Price RM"+twoDigits.format(pricey) + "\n Discounted amount RM"+twoDigits.format(total)+
"\nNet Price RM"+twoDigits.format(pricey -total);



JOptionPane.showMessageDialog(null,output,"Price",JOptionPane.INFORMATION_MESSAGE);




}

if (pricey >= 200.00){
total = (double)pricey / 100*DisExp;


output = "Order Price RM"+twoDigits.format(pricey) + "\n Discounted amount RM"+twoDigits.format(total)+
"\nNet Price RM"+twoDigits.format(pricey -total);



JOptionPane.showMessageDialog(null,output,"Price",JOptionPane.INFORMATION_MESSAGE);



System.exit(0);
}




}





}


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 11:58 am 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
can anyone help? plz


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 8:58 pm 
Offline

Joined: Mon May 21, 2007 11:39 am
Posts: 2
looks like u still need to get a bit of work done, i would help but this was just a quick login as im busy if no 1 has helped you b4 i am able to help ill try and whip up somthing to help


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 5:10 am 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
Plz do help ..i still cant make the while loop ..sigh..
quite hard ... =.= i tried alot..but still couldn't work..


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 1:58 pm 
Offline

Joined: Fri May 18, 2007 7:05 am
Posts: 7
>< how to do..can ayone help me??


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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:  
cron
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