what are the inputs and outputs? Input from the following collection in order as
ID: 3704435 • Letter: W
Question
what are the inputs and outputs?
Input from the following collection in order as required: {22, 9, 5, 7, 6, 0, -8}
/* Quiz 10 Java code*/
import java.io.*;
public class Quiz10Driver
{
public static void main(String args[]) throws IOException
{
Quiz10 app;
app = new Quiz10();
app.appMain();
}
}
class Quiz10
{
BufferedReader stdin;
int num, count, low, count2;
float tot, sum;
public void appMain () throws IOException
{
init ();
do
{
loops();
}
while (count < 5);
rptOut();
}
public void init ()
{
stdin = new BufferedReader (new InputStreamReader(System.in));
tot = count = 0;
low = 10;
}
public void loop() throws IOException
{
sum = count2 = 0;
System.out.print ( "Enter value for num: ");
num = Integer.parseInt(stdin.redLine());
While (count2 < 2)
{
repeart ();
}
if (num < low)
{
low = num;
System.out.println ("count " + count);
}
count++;
tot += sum;
System.out.println("sum / count2 = " + sum / count2);
public void repeat ()
{
sum += num;
++count2;
}
public void rptOut ()
{
System.out.println ("tot = " + tot);
System.out.println ("low = " + low);
System.out.println ("sum = " + sum);
}
}
Explanation / Answer
import java.io.*;
public class Quiz10Driver
{
public static void main(String args[]) throws IOException
{
Quiz10 app;
app = new Quiz10();
app.appMain();
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Quiz10
{
BufferedReader stdin;
int num, count, low, count2;
float tot, sum;
public void appMain() throws IOException
{
init();
do
{
loop();
}
while (count < 5);
rptOut();
}
public void init()
{
stdin = new BufferedReader(new InputStreamReader(System.in));
tot = count = 0;
low = 10;
}
public void loop() throws IOException
{
sum = count2 = 0;
System.out.print("Enter value for num: ");
num = Integer.parseInt(stdin.readLine());
while (count2 < 2)
{
repeat();
}
if (num < low)
{
low = num;
System.out.println("count " + count);
}
count++;
tot += sum;
System.out.println("sum / count2 = " + (sum / count2));
}
public void repeat()
{
sum += num;
++count2;
}
public void rptOut()
{
System.out.println("tot = " + tot);
System.out.println("low = " + low);
System.out.println("sum = " + sum);
}
}
Output
Enter value for num: 9
count 0
sum / count2 = 9.0
Enter value for num: 10
sum / count2 = 10.0
Enter value for num: 25
sum / count2 = 25.0
Enter value for num: 0
count 3
sum / count2 = 0.0
Enter value for num: 0
sum / count2 = 0.0
tot = 88.0
low = 0
sum = 0.0
your requirements are not exactly clear .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.