Question: Write a program that prompts the user to enter an integer number n that is greater than 2 . If not a valid number, looping

Write a program that prompts the user to enter an integer number n that is greater than 2. If not a valid number, looping till you get a valid one. Then, use LOOPING to calculate the sum of 1.02+1.03+1.04+dots+1.0n.(note: have to use looping for credit) USE THE STARTER CODE BELOW
This program will calculate the sum of 12+13+dots1n with any given integer number n.
Please enter an integer greater than 2
0
Your number is not greater than 2. Please enter a new number:
1
Your number is not greater than 2. Please enter a new number:
2
Your number is not greater than 2. Please enter a new number:
6
The result of 12+13dotsdots+16 is 1.45//starter code
import java.util.Scanner;
public class Test2Q1{
public static void main(String[] args){
System.out.println("This program will calculate the sum of 1.02+1.03+dots1.0n
with any given integer number n.");
Scanner input = new Scanner(
System.in);
int n=0;
System.out.println("Please enter an integer greater than 2");
// first, looping to get a valid number (hint: use input.hasNextInt() and/or use while )(2).
//2nd, use looping to calculate the sum of 1.02+1.03+1.04dots+1.0n.
}
 Write a program that prompts the user to enter an integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!