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

  Create your own date class

You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program:

  Write java program to compute how much federal need to pay

Write a java application to calculate how much federal and state tax you need to pay. The program should accomplish the following task.

  Write an array where the user can input 7 temperatures

Write an array where the user can input 7 temperatures; include a 'for' loop. Make sure the temperatures are larger than -100 and smaller than or equal to 120, if not, make sure the user enters a valid number. Make sure the temperature is between the..

  Write java program to print price of table-furniture company

Write down the Java program for furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate the price of table produced with chosen wood.

  Develop a gui based java program

Designing and developing a College Registration program

  Java class to accept a user-s hourly rate of pay

Write a class that accepts a user's hourly rate of pay and the number of hours worked. Display the user's gross pay, the withholding tax (15% of gross pay), and the net pay (gross pay - withholding).

  Write java program to print strings given at command line

Write a program Average.java which just prints strings that it is given at command line, one per line. If nothing is given at command line, print "No arguments".

  Java application to generate three-digit random number

Write a Java application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers.

  Technical community blog

Write a blog article for a coding and technical community blog.

  Java program to read line of text which ends with period

Write down the java program which will read the line of text which ends with the period, which serves as sentinel value. Show all the letters which occur in the text.

  Application for an animal-fur trimming service

Create an application for an animal-fur trimming service. Write the code for the application. Prompt the user to indicate how many animals. Display the total fee for one year. Be pleasant in your output as it will be expensive.

  Write a recursive public method

Write a recursive public method in our BST class that returns a reference to the information in the node containing the smallest value in the tree. The signature of the method is

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