Wednesday, September 9, 2009

assigment4

nie la asgmnt yg memeningkan tiap2 mgu..
aduh.. biol otak ktorg tau...
meh ak bwk korg ke alm progrmng...
hehek..

import java.util.Scanner;
public class discounts{
public static void main(String[]args)

{
Scanner input=new Scanner(System.in);
//declare the variable

int numberItems;
double price = 0,totalPrice;
double discounts = 0,zdiscounts;
//enter numberItems

System.out.print("enter numberItems:");
numberItems=input.nextInt();
//enter price

System.out.print("Enter price:");
price = input.nextDouble();
if (numberItems <>
{ if (price <=10)
discounts = 0;
else if (price <=100)
discounts = 0.02;
else
discounts = 0.05; }

else if (numberItems <>
{ if (price <=10)
discounts = 0.05;
else if (price <=100)
discounts = 0.07;
else
discounts = 0.09; }
else if (numberItems <>
{ if (price <=10)
discounts = 0.09;
else if (price <=100)
discounts = 0.15;
else
discounts = 0.21;
}
else if (numberItems <>
{ if (price <=10)
discounts = 0.14;
else if (price <=100)
discounts = 0.23;
else
discounts = 0.32;
}
else if (numberItems > 1000)

{ if (price <=10)
discounts = 0.21;
else if (price <=100)
discounts = 0.32;
else
discounts = 0.43;
}
else

System.out.print("End of program");
//calculate discount

zdiscounts = discounts * price;
//calculate price after discount

totalPrice = price - zdiscounts;
//display discount

System.out.printf("The total price after discount is = RM%.2f\n", totalPrice);
}
}

ckup r ak ltak st soklan...t ade lak yg poning tgok aknyer keje nie..
hehehek..ape nk jd pown ak xtau...

0 comments: