Question: Getting started: 1. Create a new BlueJ project called Lab5. Make sure you save your project to a flash drive or some other kind of


Getting started: 1. Create a new BlueJ project called "Lab5". Make sure you save your project to a flash drive or some other kind of permanent storage. 2. Within your Lab5 project, create a new class called "Lab5". 3. In the Lab5 class, delete all the code that BlueJ added so that you end up with a blank file. 4. Type the following code into your Lab5 class: import java.util.Scanner; public class Lab5 { public static void main(String args[]) { Scanner input = new Scanner (System.in); // Put all of your code here. } 5. Press the "Compile button and make sure there are no syntax errors. Put all of your code for this lab inside the main method, as indicated in the code above. Follow the instructions in the Requirements section to see what you have to do. Requirements: Write code that satisfies the following requirements: 1. Prompt the user to enter two non-negative integers. 2. Read in two integers from the user using input. You should not assume that the user will input the integers in a particular order. If the user enters a negative integer, then print an appropriate crror message and repeat this step. 3. Print out the sum of all the digits of all the numbers between (and including) the two numbers. For example, if the two numbers entered are 1 and 11, then your program should output 48. COMP SCI 221 Lab 5 - Page 2 of 2 3/3/2021 4. Follow the input and output scheme EXACTLY (see the Sample run section below). 5. ONLY use concepts covered up through zc5, in addition to any code that I provide for you. Hint: First, get your program to compute the sum of the digits of just one positive integer. Then, modify your program to compute the sum of all the digits between (and including) two numbers, starting at the first, and going up to the second. Then, get your program to handle the case where the first number is not less than or equal to the second number. Finally, add code up near the top of your program that loops while either input value is negative. Sample run: Your input and output format should match exactly with what is shown below: Enter two non-negative integers: 2 -1 Non-negative integers are required. Enter two non-negative integers: 2 17 Sum of all the digits: 80
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
