// This code contains ERRORS!
// It adds two numbers entered by the user.
int1 num1, num2;
String input;
char again;
Scanner keyboard = new Scanner(System.in);
while (again == ‘y’ || again == ‘Y’)
System.out.print(“Enter a number; ”);
num1 = keyboard.nextInt();
System.out.print(“Enter another number: ”;
num2 = keyboard.nextInt();
System.out.println(“Their sum is ”+ (num1 + num2));
System.out.println(“Do you want to do this again? ”);
keyboard.nextLine(); // Consume remaining newline
input = keyboard.nextLine();
again = input.charAtá0ñ;
Trending nowThis is a popular solution!
Chapter 4 Solutions
MyLab Programming with Pearson eText -- Access Code Card -- for Starting Out with Java: From Control Structures through Objects
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Concepts Of Programming Languages
Java: An Introduction to Problem Solving and Programming (8th Edition)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
- # subprogram: PrintInt# author: Charles W. Kann# purpose: To print a string to the console# input: $a0 - The address of the string to print.# $a1 - The value of the int to print# returns: None# side effects: The String is printed followed by the integervalue..textPrintInt: # Print string. The string address is already in $a0 li $v0, 4 syscall # Print integer. The integer value is in $a1, and must # be first moved to $a0. move $a0, $a1 li $v0, 1 syscall # Print a new line character jal PrintNewLine #return jr $raWhen the program is run, it never ends and acts like it is stuck in an infinite loop. Helpthis colleague figure out what is wrong with the program.a. Explain what is happening in the programb. Come up with a mechanism which shows that this program is indeed in an infiniteloop.c. Come up with a solution which fixes this problem. need accurate ans otherwise you will get downvote # subprogram: PrintInt# author: Charles W. Kann# purpose: To print a string to the console# input:…arrow_forward# subprogram: PrintInt# author: Charles W. Kann# purpose: To print a string to the console# input: $a0 - The address of the string to print.# $a1 - The value of the int to print# returns: None# side effects: The String is printed followed by the integervalue..textPrintInt: # Print string. The string address is already in $a0 li $v0, 4 syscall # Print integer. The integer value is in $a1, and must # be first moved to $a0. move $a0, $a1 li $v0, 1 syscall # Print a new line character jal PrintNewLine #return jr $raWhen the program is run, it never ends and acts like it is stuck in an infinite loop. Helpthis colleague figure out what is wrong with the program.a. Explain what is happening in the programb. Come up with a mechanism which shows that this program is indeed in an infiniteloop.c. Come up with a solution which fixes this problem. need accurate ans otherwise you will get downvotearrow_forwardJAVA CODE PLEASE FINAL EXAM Part 3 Instructions: Create a java program that asks & accepts input from the user (must be int value). Then depending on the number of inputs, the program will ask the user to enter string value/s. After, the program will print the strings entered by the user line-by-line. Constraints: Create a function and call it in the main function. Use Functions With No Parameters and Return Values Use for Loop Use String Array Use Scanner Input 1. One line containing an integer Sample 2 2. One line containing string Sample Funny 3. One line containing string Sample Sadly Output Enter·the·number·of·string·array:·2 Enter·string·#1:·Funny Enter·string·#2:·Sadly You've·entered: Funny Sadlyarrow_forward
- Using a for Loop Summary In this lab the completed program should print the numbers O through 10, along with their values multiplied by 2 and by 10. You should accomplish this using a for loop instead of a counter- controlled while loop. Instructions 1. Write a for loop that uses the loop control variable to take on the values O through 10. 2. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. 3. Execute the program by clicking the Run button at the bottom of the screen. Is the output the same?arrow_forwardStrings and string manipulation Part A: Building upon an Existing Solution Redesign the solution in the following manner. Ask the user for their name and their email addresses before you display the results of the conversions. When the user enters their email address search the string for the @ symbol. If the symbol is not found, ask the user to re-enter their email address till they get it right. When you display the conversion output to the user, you must include the user’s name in the output. Part B: Write Something New! Write a complete and syntactically correct Python program to solve the following problem: Input a date in numeric format from the user e.g. mm/dd/yy. Examine the month entered by the user, if it is larger than 12 or smaller than 1, issue an error message and ask for input again. Perform similar validation tests for the date and year. Year must be 2015. (Any other year is invalid). In addition, the year must only be two digits long.. Once all input has been…arrow_forwardComputer Science Short Answer Write a program that uses the Scanner to ask the user for an integer, but forces the user to repeatedly re-enter the number until they enter a negative value. Then if the number is odd, print it out. Otherwise, check if the number is less than -10 and if so, print it out twice. For example: 4 you would be forced to re-enter -3 is printed once -8 is not printed -13 is printed once -40 is printed twice.arrow_forward
- C++ languagearrow_forward99 question Reza Enterprises sells tickets for buses, tours, and other travel services. Because Reza frequently mistypes long ticket numbers, Reza Enterprises has asked his students to write an application that shows if a ticket is invalid. Your application/program tells the ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you lose the last digit of the number, then divide by 7, the remainder of the division is exactly the same to the last dropped digit. This process is shown below: Step 1: Enter the ticket number; for example 123454 Step 2: Remove the last digit, leaving 12345 Step 3: Determine the remainder when the ticket number from step 2 is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4. Step 4: Display a message to the ticket agent indicating whether the ticket number is valid or not. If the ticket number is valid, save the number to a .txt file called “tickets.txt” and.arrow_forwardMPI Lab Directions Write an MPI program, countprimes which will count the number of prime numbers in the numbers from 1 to n inclusive where n is a long integer. The value for n which should be set in the program using a constant should be 50,000. Each process will test its share of the cases. Each process should not print out any primes that it finds, but it should keep a running total. Before the process finishes, it should print out its ID number and its count of primes that it found. The master process should end with printing a total for the count of the number of primes and the total amount of time taken to find all the primes. Take a screenshot of the output for running this with 5 processes. Before submission, make sure you clean up the directories so that no miscellaneous files are kept around in the submission. (Grade would be deducted if useless files are found in the homework directories.) Include the source code, screenshot, and the Makefile in the submission. Your…arrow_forward
- Warm-up: Integer Operations Write a program that asks the user to enter two integers and prints the Difference, Product, Area of an Ellipse, and Average of these numbers. Here is an example of the execution of the program:arrow_forwardUser Defined Function: Void Function Create a JAVA program that will add, subtract, multiply and divide two numbers. Use user defined function for each operator Any number divided by zero will result to undefined Use int or double data type only for all variables declaredEXPECTED OUTPUT:arrow_forward17. Math Tutor Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as 247 +129 The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution: 247 +129 376arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr