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

  It should have an if statement

The following are hints given: It should have an if statement. This add method determines what number greater than or less than the other number, than it adds the positive or negative. I think this should be a private method.

  Create a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Insert uml design diagrams, use case, classes

Insert UML design diagrams here (use case, class, and sequence diagram).

  Java program to compute invoice for client

You need a java program to compute the invoice for client and then print out invoice to the screen. The consulting rate is $200 per hour.

  Java application to permit user to enter ten numbers

Write down Java application which permits a user to enter 10 numbers (double precision) into the array and then sorts and displays numbers from lowest to highest.

  Please write the code in java

Please write the code in java for  Recursion,  Sorting and Searching

  Record managing system application

Build a student record managing system application

  Write a java program in a netbeans project

Write a Java program in a NetBeans project

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Write java program to accept two words as input

Write a Java program that accepts two words as input and determines if one of them is resulting from changing the order of the others' letters.

  Write a class array that encapsulates an array

Write a class Array that encapsulates an array and provides bounds-checked access. The private instance variables should be int index and inarray[10]. The public members should be a default constructor and methods (signatures shown below) to provide ..

  Java program for creating a order menu

Assume your consulting company has been hired to construct a program that meets the following requirements.

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