java - Using Scanner...Error: '.class' expected -
getdiscountedbill() return final amount of bill
if bill >2000, bill receives 15% discount
public class discount { private double bill; private double discount; private double amt; public static double getdiscountedbill(double bill) { if (bill > 2000) { discount = bill * .15; amt = bill - discount; } return amt; if (bill <= 2000) { return bill; } } public void print() { system.out.println("bill after discount :: "); system.out.printf("%.2f\n", amt); }
code in main
public static void main( string args[] ) { scanner keyboard = new scanner(system.in); out.print("enter original bill amount :: "); double amt = keyboard.nextdouble(); keyboard.getdiscountedbill(double); keyboard.print();
error message:error: '.class' expected keyboard.getdiscountedbill(double);
change statement:
keyboard.getdiscountedbill(double);
with one:
double discuontedbill = getdiscountedbill(amt);
you're supposed pass value method argument, not pass type .
Comments
Post a Comment