Hi can you check my program if i make a inheritance. Because my teacher want us to use inheritance in jdoodle to run our program. I am still learning. Can you correct my program if its i don't use inheritance. Thanks. import java.util.*; public class QuizBee { public static void main(String args[]) { int count=0; Scanner sc=new Scanner(System.in); char[] options={'A','B','C','A','B','C','A','B','C','A'}; for(int i=0;i='A' && ans='D' && ans

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Hi can you check my program if i make a inheritance. Because my teacher want us to use inheritance in jdoodle to run our program. I am still learning. Can you correct my program if its i don't use inheritance. Thanks. import java.util.*; public class QuizBee { public static void main(String args[]) { int count=0; Scanner sc=new Scanner(System.in); char[] options={'A','B','C','A','B','C','A','B','C','A'}; for(int i=0;i='A' && ans='D' && ans
1 import java.util.*;
2- public class QuizBee {
public static void main(String args[]) {
int count-e;
Scanner sc-new Scanner(System.in);
char[] options-{'A', 'B','C', 'A', 8','C','A', 'B','C','A"};
for (int i-0;i<10;i++){
while(true){
System.out.print("Enter answer for question "+(i+1)+": ");
char ans-sc.next().charAt(0);
ans-Character.toUpperCase(ans);
try{
if(ans--options[i]){
3-
4
5
6.
7-
8-
9
10
11
12
13-
count++;
break;
14
15
16
else if(ans>-'A' && ansc-'C')
break;
else if(ans>='D' && ans<='Z')
throw new InputMismatchException("An Invalid Character");
else if(ans =='')
throw new InputMismatchException("Blank value is not allowed");
17
18
19
20
21
22
23
else
24
throw new InputMismatchException("Number or Special character is not allowed");
25
catch(InputMismatchException e){
System.out.println(e.getMessage());
26-
27
28
29
30
System.out.println("Score: "+(count*2));
System.out.println("Correct answer count(each question carries 2 marks): "+count);
System.out.println("Incorrect answer count: "+(10-count));
31
32
33
34
35 )
Transcribed Image Text:1 import java.util.*; 2- public class QuizBee { public static void main(String args[]) { int count-e; Scanner sc-new Scanner(System.in); char[] options-{'A', 'B','C', 'A', 8','C','A', 'B','C','A"}; for (int i-0;i<10;i++){ while(true){ System.out.print("Enter answer for question "+(i+1)+": "); char ans-sc.next().charAt(0); ans-Character.toUpperCase(ans); try{ if(ans--options[i]){ 3- 4 5 6. 7- 8- 9 10 11 12 13- count++; break; 14 15 16 else if(ans>-'A' && ansc-'C') break; else if(ans>='D' && ans<='Z') throw new InputMismatchException("An Invalid Character"); else if(ans =='') throw new InputMismatchException("Blank value is not allowed"); 17 18 19 20 21 22 23 else 24 throw new InputMismatchException("Number or Special character is not allowed"); 25 catch(InputMismatchException e){ System.out.println(e.getMessage()); 26- 27 28 29 30 System.out.println("Score: "+(count*2)); System.out.println("Correct answer count(each question carries 2 marks): "+count); System.out.println("Incorrect answer count: "+(10-count)); 31 32 33 34 35 )
v Execute Mode, Version, Inputs & Arguments
CommandLine Arguments
JDK 17.0.1
Interactive
> Execute
...
Result
compiled and executed in 56.368 sec(s)
Enter answer for question 1: A
Enter answer for question 2: B
Enter answer for question 3: C
Enter answer for question 4: C
Enter answer for question 5: B
Enter answer for question 6: A
Enter answer for question 7: A
Enter answer for question 81 B
Enter answer for question 9: A
Enter answer for question 10: A
Score: 14
Correct answer count(each question carries 2 marks): 7
Incorrect answer count: 3
Transcribed Image Text:v Execute Mode, Version, Inputs & Arguments CommandLine Arguments JDK 17.0.1 Interactive > Execute ... Result compiled and executed in 56.368 sec(s) Enter answer for question 1: A Enter answer for question 2: B Enter answer for question 3: C Enter answer for question 4: C Enter answer for question 5: B Enter answer for question 6: A Enter answer for question 7: A Enter answer for question 81 B Enter answer for question 9: A Enter answer for question 10: A Score: 14 Correct answer count(each question carries 2 marks): 7 Incorrect answer count: 3
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY