It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

Anyone can help me ?? i dono how to start??

Anyone can help me ?? i dono how to start??

Postby shadachi on Fri May 18, 2007 6:13 am

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
shadachi
 
Posts: 7
Joined: Fri May 18, 2007 6:05 am

Postby Stiks on Sun May 20, 2007 5:26 am

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: Select all

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.
Stiks
 
Posts: 7
Joined: Wed Apr 18, 2007 2:25 am

Postby shadachi on Sun May 20, 2007 1:21 pm

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

Postby Stiks on Sun May 20, 2007 5:41 pm

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.
Stiks
 
Posts: 7
Joined: Wed Apr 18, 2007 2:25 am

Postby shadachi on Sun May 20, 2007 6:07 pm

i am currently using JCreator..

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

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




}





}
shadachi
 
Posts: 7
Joined: Fri May 18, 2007 6:05 am

Postby shadachi on Tue May 22, 2007 10:58 am

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

Postby cybernetic on Tue May 22, 2007 7:58 pm

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
cybernetic
 
Posts: 2
Joined: Mon May 21, 2007 10:39 am

Postby shadachi on Wed May 23, 2007 4:10 am

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

Postby shadachi on Mon May 28, 2007 12:58 pm

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


Who is online

Users browsing this forum: No registered users and 0 guests