Computer Science, asked by zaidialifa2, 28 days ago

Ans this program in java​

Attachments:

Answers

Answered by BrainlyProgrammer
4

Required Answer:-

import java.util.*;

class abc{

public static void main (String ar []){

Scanner sc=new Scanner(System.in);

System.out.println("Enter name:-");

String name=sc.nextLine();

System.out.println("Enter units consumed");

int units=sc.nextInt();

System.out.println("Enter discount %");

double discount=sc.nextDouble();

double rate=0.0

if (units<=100)

rate=units*5.0;

else if((units>100)&&(units<=300))

rate=(5.0*100)+(units-100)*6.5;

else

rate=(5.0*100)+(200*6.5)+(units-300)*7.5;

System.out.println("====\nName:"+name);

System.out.println("Cost after discount:"+(rate-(discount/100)*rate));

}

}

Similar questions