Using Import Scanner instead of Savitch.In

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) {
        if(days==0)
            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!
chilax4uAsked:
Who is Participating?
 
aozarovCommented:
From the java.util.Scanner javadoc:
Scanner sc = Scanner.create(System.in);
int i = sc.nextInt();

So, import java.util.Scanner and change
  //    days = SavitchIn.readLineInt();
to
  days = sc.nextInt();
0
 
riaancorneliusCommented:
 //    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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.