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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -