1.) Write a java program that reads five integers and determines and prints the
ID: 665027 • Letter: 1
Question
1.) Write a java program that reads five integers and determines and prints the largest and smallest integers in the group?
2.)write a java program that reads two integers determines whether the first is a multiple of second and prints the result?
3.)write a java program that inputs one number consisting of five digits from the user seperates the number into its individual digits and prints the digits seperated from one another by three spaces each.For example,if the user types in the number 42339 the program should print
4 2 3 3 9
4.)write a java program that calculates the squares and cubes of the numbers from 0 to 10 and prints the resulting values in table format
number square cube
0 0 0
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000
5.)write a java program that inputs five numbers and determines and prints the number of negative numbers input,the number of positive numbers input and the number of zeros input?
Explanation / Answer
ans 1. Write a java program that reads five integers and determines and prints the largest and smallest integers in the group?
ans :
public class findmaxmin{
02
03
int input, a[5],min,max;
04
05
//Store elements
06
public int IntegerInput(){
07
08
Scanner sc = new Scanner(System.in);
09
10
for (int i=0;i<5;i++)
11
{
12
input = sc.nextInt();
13
a[i] = input;
14
}
15
16
17
}
18
19
//Find minimum
20
public int findmin()
21
{
22
min = a[0];
23
for (i=0;i< 5;i++)
24
{
25
if (min > a[i])
26
min = input;
27
}
28
29
//Find Maximum
30
public int findmax()
31
{
32
max=a[0];
33
for (i=0;i< 5;i++)
34
{
35
36
if (max < input)
37
max = input;
38
}
39
40
}
41
public static void main(String[]args){
42
findmaxmin m = new findmaxmin();
43
m.IntegerInput();
44
m.findmin();
45
m.findmax();
46
}
47
}
public class findmaxmin{
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.