Computer Science, asked by Ramyasa, 1 year ago

write a program in Java to input CP and SP and trying profit and profit percentage using if condition

Answers

Answered by shardul1925
1
Hello!!!

Your answer-

import java.util.Scanner;
public class Profit
{
public static void main(String[] args) {
double c,s,p,l ;
Scanner in = new Scanner(System.in);
System.out.println("Enter CP");
c = in.nextDouble();
System.out.println("Enter Sp");
s = in.nextDouble();
if(c<s) {
p = (s - c);
System.out.println("Profit=" + p);
}
else if (c>s){
System.out.println("Loss=" + (c-s));
} else {
System.out.println ("There is no loss or gain.")
}
}
}


Hope it helps:)
Similar questions
Math, 1 year ago