illegal start type, HELP!

illegal start type, HELP!

import java.util.Scanner;

public class Lab6ex9 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in);

    System.out.print("Please type the total number of books: ");
    int books = keyboard.nextInt();

    System.out.print("Please type the total value of the purchase: ");
    double total = keyboard.nextDouble();

    if (total >= 50)
    {
        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping is free!");
    }
    else if(total < 50 && books =< 3)
    {
        double shipping = total *0.1;

        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping cost is " + shipping + " dollars.");
    }
    else if(total < 50 && books >= 3 && books < 10)
    {
        double shipping = total *0.2;

        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping cost is " + shipping + " dollars.");
    }
    else if(total < 50 && books >= 10)
    {
        double shipping = total *0.3

        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping cost is " + shipping + " dollars.");
    }
}

}

Illegal start type error? help?

View Answers

October 18, 2011 at 10:30 AM

import java.util.Scanner;

public class Lab6ex9 {
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);

    System.out.print("Please type the total number of books: ");
    int books = keyboard.nextInt();

    System.out.print("Please type the total value of the purchase: ");
    double total = keyboard.nextDouble();

    if (total >= 50)
    {
        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping is free!");
    }
    else if(total < 50 && books <= 3)
    {
        double shipping = total *0.1;

        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping cost is " + shipping + " dollars.");
    }
    else if(total < 50 && books >= 3 && books < 10)
    {
        double shipping = total *0.2;

        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping cost is " + shipping + " dollars.");
    }
    else if(total < 50 && books >= 10)
    {
        double shipping = total *0.3;

        System.out.println("Total number of books: " + books);
        System.out.println("Total value of books: " + total);
        System.out.println("Shipping cost is " + shipping + " dollars.");
    }
}

}

October 18, 2011 at 10:41 AM

Hi Now the is running here......

I think you have made mistake here

double shipping = total *0.3 please insert semicolon after the expression

import java.util.Scanner;

public class ScannerExample {
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        System.out.print("Please type the total number of books: ");
        int books = keyboard.nextInt();

        System.out.print("Please type the total value of the purchase: ");
        double total = keyboard.nextDouble();

        if (total >= 50) {
            System.out.println("Total number of books: " + books);
            System.out.println("Total value of books: " + total);
            System.out.println("Shipping is free!");
        } else if (total < 50 && books <= 3) {
            double shipping = total * 0.1;

            System.out.println("Total number of books: " + books);
            System.out.println("Total value of books: " + total);
            System.out.println("Shipping cost is " + shipping + " dollars.");
        } else if (total < 50 && books >= 3 && books < 10) {
            double shipping = total * 0.2;

            System.out.println("Total number of books: " + books);
            System.out.println("Total value of books: " + total);
            System.out.println("Shipping cost is " + shipping + " dollars.");
        } else if (total < 50 && books >= 10) {
            double shipping = total * 0.3;

            System.out.println("Total number of books: " + books);
            System.out.println("Total value of books: " + total);
            System.out.println("Shipping cost is " + shipping + " dollars.");
        }
    }
}









Related Tutorials/Questions & Answers:

Ads