forked from DaffaTakarai/HacktoberFest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotenterx.java
More file actions
36 lines (31 loc) · 913 Bytes
/
notenterx.java
File metadata and controls
36 lines (31 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This program takes input till 'x' is not entered and give total sum of all entered values and also give largest entered number.
import java.util.*;
class notenterX{
public static void main(String arr[]){
Scanner scan = new Scanner(System.in);
String n;
int i=0,a;
int large=0;
while(true){
System.out.println("Enter values-: ");
n=scan.next();
if("x".equals(n))
{
break;
}
else{
i=i+Integer.parseInt(n);
a=Integer.parseInt(n);
if(large<a)
{
large=a;
}
else{
continue;
}
}
}
System.out.println("total sum -: "+i);
System.out.println("the largest number -: "+large );
}
}