Computer Science, asked by kunalvishnoi2018, 1 year ago

please write this Java program​

Attachments:

Answers

Answered by neha009
2

Answer:

import java.util.*;

class Purchase{

public static void  main(String args[]){

Scanner in =new Scanner(System.in);

int cp,sp=0,dis=0,year;

System.out.println("Enter the original price of car");

cp=in.nextInt();

System.out.println("Enter the number of years used");

year=in.nextInt();

switch(year)

{

case 1:

dis= 0.1*cp;

break;

case 2:

dis= 0.2*cp;

braek;

case 3:

dis= 0.3*cp;

break;

case 4:

dis= 0.5*cp;

break;

default:

dis= 0.6*cp;

}

System.out.println(" original price of car= "+cp);

System.out.println("Depreciated price of car= "+dis);

System.out.println("Selling price of car= "cp-dis);

}

}

Explanation:

Above code is written in java using scanner class

the program makes use of the switch statement for the flow of control

hope it helps you!


kunalvishnoi2018: Thank you very much for your help
Answered by ayushdasgupta
0

Answer:

//program to find the depreciated value

import java.util.*;

public class DepreciatedValue

{

   public static void main(String args[])

   {

       Scanner sc=new Scanner(System.in);

       System.out.println("Enter 1 for one year,2 for two years,3 for three years,4 for four years or 5 for above four years");

       System.out.println("Enter your choice");

       int n=sc.nextInt();

       System.out.println("Enter the original price");

       int p=sc.nextInt();

       double dp,amt=0.0;

       switch(n)

       {

           case 1:

           dp=10.0/100.0*p;

           amt=p-dp;

           System.out.println("The price to be paid by the customer="+amt);

           break;

           case 2:

           dp=20.0/100.0*p;

           amt=p-dp;

           System.out.println("The price to be paid by the customer="+amt);

           break;

           case 3:

           dp=30.0/100.0*p;

           amt=p-dp;

           System.out.println("The price to be paid by the customer="+amt);

           break;

           case 4:

           dp=50.0/100.0*p;

           amt=p-dp;

           System.out.println("The price to be paid by the customer="+amt);

           break;

           case 5:

           dp=60.0/100.0*p;

           amt=p-dp;

           System.out.println("The price to be paid by the customer="+amt);

           break;

           default:

           System.out.println("Wrong Category");

       }

   }

}

           

Explanation:

Just follow my steps it is simple

Similar questions