write a program to input the cost price and the selling price of an article.If the selling price is more than the cost price then calculate and display actual profit and profit percent otherwise,calculate and display actual loss and loss percent.if the cost price and selling price are equal,the program displays the message'Neither profit nor loss'.
Answers
Answer:
import java.util.*;
class program
{
public static void main ( string args [ ])
{
Scanner sc = new Scanner ( System.in)
System.out.println("Input the cost price of the article")
int cp=sc.nextInt()
System.out.println("Input the selling price of the article")
int sp=sc.nextInt()
if(sp>cp)
int profit = sp - cp ;
int profit percent = (profit/cp)*100;
System.out.println("Profit ="+profit)
System.out.println("Profit percent =" + profit percent)
if(sp<cp)
int loss = cp - sp;
int loss percent = (loss / cp)*100;
System.out.println("Loss ="+loss)
System.out.println("Loss Percent ="+loss percent )
if(sp=cp)
System.out.println("Neither Profit nor loss ")
}}
Answer:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.util.Scanner;
class AreaOfCircle
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
System.out.println("Enter the radius:");
double r= s.nextDouble();
double area=(22*r*r)/7 ;
System.out.println("Area of Circle is: " + area);
}
}
Explanation: