Application that generates a quiz

Assignment Help JAVA Programming
Reference no: EM13160194

Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture. When the user selects the correct answer, a message of positive reinforcement should be displayed. If the user selects the incorrect answer, the correct answer should be displayed with a message of constructive criticism. At the end of the quiz, display the number of correct and incorrect answers as well as the percentage of correct responses for each user. Make sure to address users by name and confirm or deny the correlation between their score and their perceived confidence in test taking.

Your code and output should show input and results for three different users taking the quiz. You cannot be one of the users. Make sure you use all the skills studied in the course, including proper comments, Scannerclass, several looping structures, and clean code without errors in any areas.

Code:

import java.util.Scanner;
public class HorticultureQuiz {
public static void main(String args[]){
String name;
String major;
String confidence;
Scanner input=new Scanner(System.in);
int correct=0, incorrect=0;
double CorrectPct;
String[] Questions=new String[]{"Question 1","Question 2","Question 3","Question 4","Question 5"};
boolean[] AnswerKey=new boolean[]{true, true,false,true,false}; //or whatever answer is
String[] Response =new String[]{"That's correct! Keep it up!","Sorry, wrong answer. Keep trying!"};
String answer;
System.out.print("Enter your first name: ");
name=input.next();
System.out.print("Enter your Major(one word): ");
major=input.next();
//get valid confidence
do{
System.out.print("Enter your confidence level( 'high','medium','low'): ");
confidence=input.next();
if(! (confidence.equals("high")||confidence.equals("medium")||confidence.equals("low"))){
System.out.print("What was that? We did not catch that.");
}
}while(! (confidence.equals("high")||confidence.equals("medium")||confidence.equals("low")));
//question time
for(int i=0;i<Questions.length;){
System.out.printf("\nQuestion %d\nT or F: %s\n",i+1,Questions[i] );
answer=input.next();
if(answer.equals("T")||answer.equals("t")){
if(AnswerKey[i]==true){
correct++;
System.out.println(Response[0]);
}
else{
incorrect++;
System.out.println(Response[1]);
}
++;
}
else if(answer.equals("F")||answer.equals("f")){
if(AnswerKey[i]==false){
correct++;
System.out.println(Response[0]);
}
else{
incorrect++;
System.out.println(Response[1]);
}
i++;
}
else{
System.out.println("An invalid response was entered. Please enter 'T'or 'F' only");
}
}//end for
System.out.printf("%s, you got %d questions correct and %d questions wrong.",name,correct,incorrect);
System.out.printf("Your correct percentile is %.1f%%.",(float)correct*100/(float)(incorrect+correct));
input.close();
}//end main
}

Reference no: EM13160194

Questions Cloud

Calculate your price elasticity of demand of widgets : Calculate your price elasticity of demand of widgets. What can you say about your price elasticity of demand of widgets?
Cost versus usage percentages be assessed and analyzed : How should cost versus usage percentages be assessed and Analyzed? This area will need to address actual costs compared to edible portion costs. It should also include how waste affects costs. 100-150 words
What is the frequency of t : The ability of certain people to taste a chemical called PTC isgoverned by a dominant allele T, and the inability to taste PTC byits recessive t. If 24% of the population is homozygous dominantand 49% is heterozygous, what is the frequency of t?
Illustrate the effect of an increase in p2 on consumption : illustrate the effect of an increase in P2 on the consumption of both x1 and x2. Label income and substitution effects for both goods.
Application that generates a quiz : Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture. When the user ..
Calculate the total interest expense and interest payable : Calculate the total interest expense and interest payable from February 1 to August 31, 2010. Prepare the journal entry at August 31, 2010, to bring the accounting records up to date.
What mass of potassium hydroxide should the student dissolve : A student wants to prepare exactly 1000 mL of a 0.500 M aqueous potassium hydroxide solution. What mass of potassium hydroxide should the student dissolve in the solution?
Find the allele frequencies : White wool is dependent upon a dominant allele B and black woolupon its recessive b. A sample of Rambouill breed in Idaho gave thefollowing data: 891 white and 9 black. Find the allele frequencies.
Compute the gain or loss to settle the debt : Mann Inc which owes Doran Co $600,000 in notes payable with accrued interest of $54,000 is financially difficulty. To settle the debt Doran agrees to accept from Mann equipment with a fair value of 570,000, an original cost of $840,000 and accumu..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Display random numbers to simulate rolling a die

1. Display random numbers to simulate rolling a die2. Create a java program that simulate a casino game. (rollin a die)

  Write a program that shows the current time and date

Write a program that shows the current time and date

  Write applet which reads five numbers-draw equivalent stars

Write the applet which reads five numbers (each between 1 and 30). For each number read, your program must design line containing that number of adjacent asterisks.

  Consider a typical certification hierarchy

Why might Bob still not trust that the certificate for Alice truly establishes Alice as the owner of the public key in the certificate?

  String that contains at least five letters

Write an application that prompts the user for a String that contains at least five letters and at least five digits. Continuously reprompt the user until a valid String is entered. Display a message indicating whether the user was successful or did ..

  Evaluate the rtas resource requirements

Design and implement a set of classes and interfaces and use them to evaluate the RTA's resource requirements.

  Sequence of method in vector class

Construct a Vector class implementing a number of vector operations as methods along with a testing program to verify the class is working.

  Create java program to find number of days left in that year

Create a Java program called "DaysLeftInYear.java" that outputs the number of days left in that year. use the calendar class to represent dates. Use the DateFormat class to display the current date in the output.

  Inheritancedemo

Create a New Project named InheritanceDemo . 2. Create a new class called Person and cut and paste the Person.java file from Blackboard into the class. Create a new class called Student and cut and paste the Student.java file from Blackboard into the..

  Create a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Write java program using array list object

Write a java program (using eclipse) using ArrayList object to allow the professor to enter student's name, his or her's four test scores.

  Wrappershallow and wrapperdeep

Each class is simply a wrapper class to hold a private array variable. int [] a; The default constructor for each class should initialize â??aâ??. Each class should have a toString() and equals(). Each class should have a setArray method that allows ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd