Answer to Question #285990 in Java | JSP | JSF for kkkkkk

Question #285990

do while loop



Sample output:



1. Write a program that asks the user for a starting value and an ending



value and then writes all the integers (inclusive) between those two values.



Enter Start:



10



Enter End:



15



10



11



12



13



14



15



Sum of in range values: 75

1
Expert's answer
2022-01-09T13:06:32-0500


import java.util.Scanner;
class TablesLab1 {
    public static void main(String[] args) {
        Scanner keyBoard = new Scanner(System.in);
        System.out.print("Enter Start:"); 
        int start=keyBoard.nextInt();
        System.out.print("Enter End:"); 
        int end=keyBoard.nextInt();
        int counter=start;
        int sum=0;
        do{
            System.out.println(counter);
            sum+=counter;
            counter++;
        }while(counter<=end);
            
        System.out.println("Sum of in range values: "+sum);
        keyBoard.close();
    }
    
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog