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");
}
}
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");
}
}
This Java program reads an integer from a keyboard and prints it out with other comments....
Part A Write a Java program that reads an integer n from the keyboard and loops until −13 ≤ n ≤ 13 is successfully entered. A do-while loop is advised. Part B Write a Java program that reads an integer n from the keyboard and prints the corresponding value n!. [This is n factorial]. You must verify that the input integer satisfies the constraint 0 ≤ n ≤ 13; keep looping until the constraint is satisfied. Will give thumbs up...
Write a program file_max.c that reads a set of integer numbers from a file and prints out the maximum number to standard output. The name of the input file should be specified as a command line argument.
Write a complete C program with a helper function that reads an integer from the keyboard and prints its factorial to the standard output
using C++ Write a program that: a) Inputs an integer n from the keyboard where n<=100. If n is out of range then print out an error message and ask for another input. This process repeats until a valid value for n is obtained. b) Inputs two 1D arrays of doubles A and B (of size n) from the keyboard. c) Inputs an integer k (from 1 to 3) from the keyboard. d) If k = 1 then it calculates...
This is a Java program Write a program that reads an unspecified number of integers, determines home many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number to 2 decimal places. System.out.println(countPositive); System.out.println(countNegative); System.out.println(total); System.out.printf("%.2f",total * 1.0 / count); Assume inputs are always integer [-912985158, 912985158] and ends with 0. Input 1 2 -1 3...
Write a program “hw4.c” that reads integer (less than or equal 100) from the keyboard and, on the output, writes the sum of the divisors of n (other than itself). For integers less than or equal to 1 it should print 0. For example, the input -3 0 1 4 5 6 12 should generate the output 0 0 0 3 1 6 16 Explanation of output: The input -3 is less than 1, output is 0. The input 0...
For Java Write a program that reads a sequence of integer inputs all on one line and prints: 1.)The smallest and largest of the inputs 2.)The number of odd and even inputs 3.)Cumulative totals. If the input is 1 7 2 9, the program prints 1 8 10 19. 4.)All adjacent duplicates. If the input is 1 3 3 4 5 5 6 6 6 2, the output is 3 5 6.
JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...
in C The preceding LML program reads two numbers from the keyboard and determines and prints the larger value. Note the use of the instruction +4107 as a conditional trans- fer of control, much the same as C's if statement. In-Class Tasks Write LML programs that accomplish each of the following tasks: Use a sentinel-controlled loop to read 10 positive integers and compute and print their sum 1. 2. Use a counter-controlled loop to read seven numbers, some positive and...
1. Write a program that reads a sequence of numbers from the keyboard, and displays the smallest number. The sequence has at least one number and is terminated by -999(-999 will not appear in the sequence other than as the end marker). 2. Write a program which requests an integer input n from the keyboard and computes the sum of square of k for all k from 1 to n(inclusive). use java