Computer Science, asked by shalini683, 1 year ago

Using scanner class method

it is a java program



Please answer it correctly

I will mark you as brainlist

Please answer it very fast

Attachments:

Answers

Answered by Anonymous
1

CODE :


import java.util.*;

class Prepaid_taxi

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter the distance travelled");

int d=sc.nextInt();

System.out.println("Enter the TAXI number");

int n=sc.nextInt();

int c=0;

if(d<=5)

{

c=d*100;

}

else if(d>5&&d<=15)

{

c=(5*100)+(15-d)*10;

}

else if(d>15&&d<=25)

{

c=(5*100)+(10*10)+(25-d)*8;

}

else

{

c=(5*100)+(10*10)+(10*8)+(d-25)*5;

}

System.out.println("Taxi No: "+n);

System.out.println("Distance travelled : "+d);

System.out.println("Charges :"+c);

}

}


IMPORTANT THINGS TO NOTE :


➡ When the distance travelled is upto 5 , then the money will be ( distance × 100 ).

➡ If distance is more than 5 , the money will be the previous charge of ( 100 × 5 ) and the remaining distance that is (15-d )× 10.

➡ The more the distance , the previous charges get added up.

➡ This kind of programs are called Dependence Slabs .


EXAMPLE :

Distance = 30

Charge = ( 5×100 ) + ( 10×10 ) + ( 10×8 ) + (d-25)×5

= > 500 + 100 + 80 + ( 30 - 25 )×5

= > 680 + 5×5

= > 680 + 25

= > 705


Thanks for the question !

__________________________________________________________________

Answered by ElegantBoi
2

hey wassup...

HCl is a strong acid whereas acetic is a weaker acid. Fizzing occurs because of the production of the hydrogen gas obtained due to reaction of the acid on the magnesium ribbon. Since HCl is a very strong acid there is a lot of liberation of hydrogen gas from test tube A. therefore, more fizzing take place in test tube A....

Similar questions