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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  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.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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