Reset author name to chosen name ✨
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package lab11_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class DoWhileEvent2 {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Please enter a positive number to add it to sum or -1 to quit");
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int num = scan.nextInt(); //2 Condition: initialize the condition of the loop
|
||||
int sum = 0; //1 task: Initialize the task
|
||||
do //1 condition: What is the condition?
|
||||
{
|
||||
sum += num; //2 task: task of the loop and its update
|
||||
System.out.println("Please enter a positive number to add it to sum or -1 to quit");
|
||||
num = scan.nextInt();//3 condition update the condition of the loop.
|
||||
}
|
||||
while (num != -1);
|
||||
System.out.println("Total " + sum);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user