AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-programming: Calculate loss and loss percentage

alaj purchased a table for Rs.200.4 and due to some scratches on its top he had to sell it for Rs.176.5. Find his loss and loss%.

LOSS : Cost Price - Selling Price

LOSS% : (LOSS/Cost Price)*100

a. Declare four double variables i.e. costprice, sellingPrice, loss, lossPercentage

b. Assign 200.4 to costPrice and 176.5 to sellingPrice.

c. Print loss and lossPercentage according to the given formulas like: 823.67 8.23 d.

For printing upto two decimal places use

System.out.printf("%.2f\n", loss);

Note:

1. output for both should be upto two decimal places

2. Output should be displayed in two different lines

corejava x 351
programming x 167
Posted On : 2016-09-17 11:36:32.0
profile Boopalan - anyforum.in Boopalan
3730
up-rate
5
down-rate

Answers


public class ProfitLoss {
public static void main(String[] args) {
double costPrice=200.4,sellingPrice=176.5,loss,lossPercentage;
loss=costPrice-sellingPrice;
lossPercentage=(loss/costPrice)*100;
System.out.printf("%.2f\n", loss);
System.out.printf("%.2f", lossPercentage);
}
}

Posted On : 2016-09-17 21:54:37
Satisfied : 1 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523187021168
Reply This Thread
up-rate
4
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in