Question: This is the code I have so far. This code presents 10 random questions out of 20 and allows the user to input an answer.

This is the code I have so far. This code presents 10 random questions out of 20 and allows the user to input an answer. This code also generates a report at the end showing which questions the user got right and wrong and what score they got over 10. What I need is the rest of the requirements outlined in the brief above such as the results being saved to the students profile, allowing the management of multiple student profiles and a generation of an overall class report, an admin access where an admin user can see all the students attempts but a user can only see their own attempts, a student login to their profile before the quiz starts, the allowance of multiple attempts which are saved against their individual profile and lastly all the questions and answers to be saved to a simple text file which is read by the quiz application.



here is the code pasted out
class Question { String q; String []option; String answer; Question(String ques,String optionA,String optionB,String optionC,String answer) { this.q=ques; this.option=new String[3]; this.option[0]=optionA; this.option[1]=optionB; this.option[2]=optionC; this.answer=answer; } public String toString() { String s; s=this.q+" "; s+="(a) "+this.option[0]+" "; s+="(b) "+this.option[1]+" "; s+="(c) "+this.option[2]+" "; return s; } }
import java.util.Scanner;
public class Quiz { public static void main(String []args) { Scanner sc=new Scanner(System.in); Question ques[]=new Question[20]; ques[0]=new Question("What does P in OOP stand for?","Place","Phone","Programming","c"); ques[1]=new Question("What is Eclipse?","A lunar event","IDE","A skateboard","b"); ques[2]=new Question("What is The V-Model?","A cat","A building","A Software Life Cycle","c"); ques[3]=new Question("What type of language is used in OOP?","Java","French","German","a"); ques[4]=new Question("What is a feature of OOP?","Two arms","Inheritance","A beak","b"); ques[5]=new Question("What is used in OOP?","Objects","Cars","Chairs","a"); ques[6]=new Question("Choose a type of inheritance used in OOP.","Hybrid inheritance","No inheritance","Some inheritance","a"); ques[7]=new Question("Who used OOP first?","Nelson Mandela","Nikola Tesla","Alan Key","c"); ques[8]=new Question("What kind of diagrams are used in OOP?","Class Diagrams","Shape Diagrams","Entrance Diagram","a"); ques[9]=new Question("What is a key aspect in OOP?","The sky","Ethics","Animals","b"); ques[10]=new Question("What must be followed when doing OOP?","People","Trucks","ACM Code of Ethics","c"); ques[11]=new Question("What is a loop that never stops?","For Loop","Infinite Loop","Full Loop","b"); ques[12]=new Question("What special value is designated for controlling a loop?","Sentinel Value","Base Value","Control Value","a"); ques[13]=new Question("What is a method?","A philosophy","A collection of statements grouped together to perform an operation","A shark","b"); ques[14]=new Question("When an exception is generated, it is said to have been what?","Created","Called","Thrown","c"); ques[15]=new Question("What does counter++; do?","Adds 1 to counter","Adds 2 to counter","Adds 3 to counter","a"); ques[16]=new Question("What is an object?","A thing","Representation of an entity in the real world that can be distinctly identified","A name","b"); ques[17]=new Question("What is an array?","A train","A house","An object that can store a group of values, all of the same type","c"); ques[18]=new Question("You use this statement to throw an exception manually.","Throw","Call stack","Try block","a"); ques[19]=new Question("What can OOP be used for?","Making a rocket","Designing applications","Cooking food","b");
//Create a array to ask 10 q's out of the 20 int arr[]=new int[ques.length/2]; for(int i=0;i { //Randomly generate question number int x=(int)(Math.random()*(ques.length)); //Check if question number repeat for(int j=0;j if(arr[j]==x) { x=(int)(Math.random()*(ques.length)); j=-1; } arr[i]=x; } int []right=new int[ques.length/2]; int []wrong=new int[ques.length/2]; int rlast=0,wlast=0,score=0; for(int i=0;i { System.out.print(" "+ques[arr[i]].toString()); System.out.print(" Choose Your Answer : "); String ans=sc.nextLine(); if(ans.equals(ques[arr[i]].answer)) { right[rlast]=arr[i]; rlast++; score++; } else{ wrong[wlast]=arr[i]; wlast++; } } System.out.println(" Your score for this quiz is "+score+ "/" + "10 "+ "or "+score *10+"%"); System.out.println(" Correct Answer(s) "); for(int i=0;i { System.out.println(ques[right[i]].toString()+"Your answer ("+ques[right[i]].answer+") was correct "); } System.out.println("Wrong Answer(s) "); for(int i=0;i { System.out.println(ques[wrong[i]].toString()+"Correct answer is ("+ques[wrong[i]].answer+") ");
} System.out.println("Scroll up to see full report "); sc.close(); } }
I have no more information to give you all the relevant information is given above, if you cannot answer the question can you please refund it so i can ask someone else.
Introduction You have been tasked with solving a software problem which is defined in the problem statement section below. The assignment has been designed to ensure full coverage of all content delivered within the module, as such, to be successful you will need to be familiar with all lecture and lab material delivered to-date and over the next 2 weeks. This assignment is worth 50% of your overall grade. Please familiarise yourself with the marking scheme at the end of this document to understand what is required as assignment deliverables. Problem statement You are required to develop a Java based Multiple Choice Quiz application to aid students taking the module "Object Oriented Analysis & Design" review content in their module. Users will be presented with a randomly chosen set of 10 questions from a question bank and be presented with a choice of solutions. The user must then chose a correct answer and move to the next question. The application will generate a report of how well the student did after the quiz has completed. The student's result is saved to their profile. The application can manage many student profiles and can generate an overall class report. The quiz may be administrated by an admin user. An admin user has full access to all student's attempts, but a student user can only see their own attempts as such Student's must login to their profile before starting the quiz. Students are allowed have multiple attempts which are all persistently saved against their individual profile. Questions and solutions are saved in a simple text file which is read by the quiz application. Question.java x D Quizjava 1 2 class Question 3 { 4 String q; 5 String (loption; 6 String answer; 7 Question(String ques, String option, String options, String optionc,string answer) 8 { 9 this.q=ques; 10 this.option=new String[3]; 11 this.option[0]-optionA; 12 this.option[1]=optionB; 13 this.option[2]=optionC; 14 this.answer=answer; 15 } 216e public String tbstring() 17 { 18 String s; 19 s=this.q+" "; 20 st="(a) "+this.option[@]+" "; 21 st="(b) "+this.option[1]+" "; 22 st="(c) "+this.option [2]+" "; 23 24 return s; 25} 26 } Question.java Quizjava x 1 import java.util.Scanner; 15 3 public class Quiz { 40 public static void main(String []args) 5 { 6 Scanner sc=new Scanner(System.in); 7 Question ques[]-new Question[20]; 8 ques[@]=new Question("What does P in OOP stand for?", "Place", "Phone", "Programming", "c"); 9 ques[1]=new Question("What is Eclipse?", "A lunar event", "IDE","A skateboard", "b"); 10 ques[2] =new Question("What is The V-Model?","A cat","A building", "A Software Life Cycle","c"); 11 ques[3] =new Question("What type of language is used in OOP?", "Java", "French", "German", "a"); 12 ques[4]=new Question("What is a feature of OOP?", "Two arms", "Inheritance", "A beak","b"); 13 ques[5]=new Question("What is used in OOP?", "Objects","Cars", "Chairs","a"); 14 ques[6]=new Question("Choose a type of inheritance used in OOP.", "Hybrid inheritance", "No inheritance", "Some inheritance", "a"); ques[7]=new Question("Who used OOP first?", "Nelson Mandela", "Nikola Tesla", "Alan Key", "c"); 16 ques[8]=new Question "what kind of diagrams are used in OOP?", "Class Diagrams", "Shape Diagrams", "Entrance Diagram", "a"); 17 ques[9]=new Question "What is a key aspect in OOP?", "The sky", "Ethics", "Animals", "b"); 18 ques[10]=new Question("What must be followed when doing OOP?", "People", "Trucks", "ACM Code of Ethics","c"); 19 ques[11]=new Question("What is a loop that never stops?", "For Loop", "Infinite Loop", "Full Loop", "b"); 20 ques[12]=new Question("What special value is designated for controlling a loop?", "Sentinel value", "Base Value", "Control Value","a"); 21 ques[13]=new Question("What is a method?", "A philosophy", "A collection of statements grouped together to perform an operation", "A shark","b"); 22 ques[14]=new Question("When an exception is generated, it is said to have been what?", "Created", "Called", "Thrown", "c"); 23 ques[15]=new Question("What does counter++; do?", "Adds 1 to counter","Adds 2 to counter","Adds 3 to counter","a"); 24 ques[16]=new Question "What is an object?", "A thing", "Representation of an entity in the real world that can be distinctly identified", "A name" 25 ques[17]=new Question("What is an array?", "A train", "A house", "An object that can store a group of values, all of the same type", "c"); 26 ques[18]=new Question("You use this statement to throw an exception manually.", "Throw", "Call stack", "Try block","a"); 27 ques[19]=new Question("What can OOP be used for?", "Making a rocket", "Designing applications", "Cooking food", "b"); 28 29 30 31 //Create a array to ask 10 q's out of the 20 32 int arr[]=new int[ques.length/2]; 33 for(int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
