Using Import Scanner instead of Savitch.In

Posted on 2005-04-18
Medium Priority
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

Assisted Solution

riaancornelius earned 150 total points
ID: 13804211
 //    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

aozarov earned 225 total points
ID: 13805543
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();
  days = sc.nextInt();

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 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