1. What value will be output first? a. 1.0 b. 2.0 c. 3.0 d. 4.0 e. none of the a
ID: 3699393 • Letter: 1
Question
1. What value will be output first?
a. 1.0
b. 2.0
c. 3.0
d. 4.0
e. none of the above
2. What value will be output next?
a. 1.0
b. 2.0
c. 3.0
d. 4.0
e. none of the above
3. What value will be output next?
a. 8.0
b. 7.0
c. 6.0
d. 5.0
e. none of the above
4. What value will be output next?
a. 3.0
b. 4.0
c. 6.0
d. 7.0
e. none of the above
5. What value will be output next?
a. 5.0
b. 7.0
c. 9.0
d. 11.0
e. none of the above
6. What value will be output next?
a. 3.0
b. 2.0
c. 1.0
d. 0.0
e. none of the above
7. What value will be output next?
a. 4.0
b. 3.0
c. 2.0
d. 1.0
e. none of the above
8. What value will be output next?
a. 4.0
b. 5.0
c. 15.0
d. 16.0
e. none of the above
9. How many values will be output?
a. 9
b. 10
c. 12
d. 14
e. none of the above
10. What value will be output last?
a. 4.0
b. 4.5
c. 5.0
d. 15.0
e. none of the above
Assume that the number value three (3) is input when appropriate
import java.io*;
Public class quiz09Driver
{
public static void main (string[] args) throws IOException
{
Quiz09 app;
app = new Quiz09();
app.appmain();
}
}
class Quiz09
{
class Quiz09
{
BufferedReader stdin;
float cA, cl, cB, tA;
public void appmain() throws IOException
{
stdin = new BufferedReader (new InputStreamReader(system.in));
rptInit();
while (cA >=cl)
{
loop();
}
rptOut();
}
void rptInit() throws IOException
{
tA = 0;
cA = 5;
cB = 2;
system.out.print("Enter value for cl:");
cl = Float.parseFloat (stdin.readLine());
}
void loop()
{
upDate1();
upDate2();
System.out.println("cA = " + cA);
}
void upDate1()
{
cA = cA -1;
tA= tA + cA;
}
void upDate2()
{
if (cA <=2)
{
cB = cB +1;
}
else
{
cB = cB +2;
}
System.out.printlin("cB =" + cB);
}
voidrptOut()
{
cB=tA/cA;
System.out.printlin(cA =" + cA);
System.out.printlin(cl =" + cl);
System.out.printlin(tA =" + tA);
System.out.printlin(cb =" + cb);
}
}
Explanation / Answer
//Programme corrected (without errors)
// Programme Name : quiz09Driver.java
import java.io.*;
public class quiz09Driver
{
public static void main (String[] args) throws IOException
{
Quiz09 app;
app = new Quiz09();
app.appmain();
}
}
class Quiz09
{
BufferedReader stdin;
float cA, cl, cB, tA;
public void appmain() throws IOException
{
stdin = new BufferedReader (new InputStreamReader(System.in));
rptInit();
while (cA >=cl)
{
loop();
}
rptOut();
}
void rptInit() throws IOException
{
tA = 0;
cA = 5;
cB = 2;
System.out.print("Enter value for cl:");
cl = Float.parseFloat (stdin.readLine());
}
void loop()
{
upDate1();
upDate2();
System.out.println("cA = " + cA);
}
void upDate1()
{
cA = cA -1;
tA= tA + cA;
}
void upDate2()
{
if (cA <=2)
{
cB = cB +1;
}
else
{
cB = cB +2;
}
System.out.println("cB =" + cB);
}
void rptOut()
{
cB=tA/cA;
System.out.println("cA =" + cA);
System.out.println("cl =" + cl);
System.out.println("tA =" + tA);
System.out.println("cB =" + cB);
}
}
Output :
Enter value for cl:3
cB =4.0
cA = 4.0
cB =6.0
cA = 3.0
cB =7.0
cA = 2.0
cA =2.0
cl =3.0
tA =9.0
cB =4.5
Questions Answers :
1. d
2. d
3. c
4. a
5. b
6. b
7. c
8. e
9. b
10. b
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.