Using Import Scanner instead of Savitch.In

Posted on 2005-04-18
Last Modified: 2012-06-27
I just realized I have to use import java.*/ instead of Savitch.In because the programming class I am in is using a fourth edition book, but some of us still hjave the third. Well, I am new to programming and I need help woth the Scanner Class please! Here is my program:

public class PenniesForPay


    public static void main(String[] args)


        /* Variables */

        int days = 0;

        /* Description of program for user. */

        System.out.println("This program will calculate your salary for a number of days");
        System.out.println("between 0 and 40, with your salary starting at $.01");
        System.out.println("and doubling for every day worked.");

        System.out.println("\nPlease enter the number of days you worked.");
        //    days = SavitchIn.readLineInt();

        /* Days entered with a value greater than 40 or less than 0 are invalid. */

        if ((days > 40) && (days < 0));
        System.out.println("You have entered an invalid number of days.");

        /* Program outputs for # of days entered. */
        for(int i=1;i<=40;i++) {
            print(i,0.1)  ;


    public static void print(int days, double value) {
        System.out.println("You worked "+days +" days. \nYour pay on day "+days+" is $"+.01*Math.pow(2,days-1)+".");
        double total=total(days,value);
        System.out.println("Your total salary is "+total);
    public static double total(int days,double value) {
            return 0;
        double total=.01*Math.pow(2,days-1)+total(days-1,value);
        return total;
This is a easy question tp a progammer, but very urgent to me since I do not have the resources! Thanks!
Question by:chilax4u
    LVL 9

    Assisted Solution

     //    days = SavitchIn.readLineInt();
    shouldn't that be days = System.In.readLineInt()
    if there is a readLineInt() method. I always use System.readLine() and just convert the text to int. I don't have any idea where the 'SavitchIn' comes from.
    LVL 15

    Accepted Solution

    From the java.util.Scanner javadoc:
    Scanner sc = Scanner.create(;
    int i = sc.nextInt();

    So, import java.util.Scanner and change
      //    days = SavitchIn.readLineInt();
      days = sc.nextInt();

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now