Question

This Java program reads an integer from a keyboard and prints it out with other comments....

This Java program reads an integer from a keyboard and prints it out with other comments. Modify the comments at the top of the program to reflect your personal information.

Submit Assignment1.java for Assignment #1 using Gradescope->Assignemnt1 on canvas.asu.edu site.

You will see that the program has a problem with our submission. Your program is tested with 4 testcases (4 sets of input and output files). In order to pass all test cases, your program needs to produce the same output as the ones given below. (Even one character difference causes failure.) This is a part of Software Engineering Testing process (that we will be discussing in class).

Input 1: 0

Output 1:

This program reads an integer from a keyboard,

and prints it out on the display screen.

Make sure that you get the exact same output as the expected one.

The read number is 0.

Input 2: -1

Output 2:

This program reads an integer from a keyboard,

and prints it out on the display screen.

Make sure that you get the exact same output as the expected one.

The read number is -1.

Input 3: 1

Output 3:

This program reads an integer from a keyboard,

and prints it out on the display screen.

Make sure that you get the exact same output as the expected one.

The read number is 1.

Input 4: -5

This program reads an integer from a keyboard,

and prints it out on the display screen.

Make sure that you get the exact same output as the expected one.

The read number is -5.

The program should follow this:

// Assignment #: 1

// Arizona State University - CSE205

// Name: Your name

// StudentID: Your Student ID

// Lecture: Your Lecture time

// Description: This class reads an integer from a keyboard and prints it out

// along with other messages.

import java.util.Scanner; // use the Scanner class located in the "java.util"

directory

public class Assignment1

{

public static void main (String[] args)

{

int number;

Scanner console = new Scanner(System.in);

number = console.nextInt(); // read an integer entered by a user

// display the number with other messages

System.out.print("This program reads an integer from a keyboard,\n"

+ " and prints it out on the display screen.\n"

+ "make sure that you get the exact same output as the expected

one.\n"

+ "The read number is: " + number + ".\n");

}

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Let me know if you have any doubts or if you need anything to change or if there is any issue while testing. I’ll resolve as soon as I can. If you are satisfied with the solution, please rate the answer. Thanks

// Assignment1.java

import java.util.Scanner;

public class Assignment1

{

    public static void main(String[] args)

    {

        int number;

        Scanner console = new Scanner(System.in);

        number = console.nextInt(); // read an integer entered by a user

        // display the number with other messages

        System.out.print("This program reads an integer from a keyboard,\n"

        + "and prints it out on the display screen.\n"

        + "Make sure that you get the exact same output as the expected one.\n"

        + "The read number is " + number + ".\n");

    }

}

Add a comment
Know the answer?
Add Answer to:
This Java program reads an integer from a keyboard and prints it out with other comments....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT