Question

In: Computer Science

Exercise Overview Implement a Java program that creates math flashcards for elementary grade students. User will...

Exercise Overview

Implement a Java program that creates math flashcards for elementary grade students. User will enter his/her name, the type (+, -, *, /), the range of the factors to be used in the problems, and the number of problems to work. The system will provide problems, evaluate user responses to the problems, score the problems, and provide statistics about the session at the end.

Functional Requirements

  • User enters name at the beginning of a session.
  • System covers four math operations – addition, subtraction, multiplication, and division – with the user choosing which of the four operations to do in the session. Only 1 type of problem can be done in each session.
  • User will enter additional session parameters from prompts – number of problems to work and the range of values desired in the problems, e.g., addition with factors ranging from 0 to 12.
  • System will present problems to the user.
  • User will respond to problems with an answer and the system will provide immediate feedback for each problem, correct or incorrect.
  • System will provide summary statistics for the session once all problems are completed, including user name, date and time, operation chosen for the problems, range selected for the problems, number of problems, number of problems correct, percentage score, duration of the session.

Technical Requirements

The system should include the following Java components:

  • Name of your source code main class as follows: YourName_Project1.java
  • Methods to prompt the user and to get values for input variables, e.g., user name, number of problems, range of values, etc.
  • Switch statement for selecting the math operation to perform (cases).
  • Loop to create the selected number of problems for the session,
  • Method to get the factors for the problems.
  • Math.random() used in the creation of the problems.
  • System.currentTimeMillis() used to record the start time, end time, and calculate the duration of the session in seconds.
  • java.time.LocalTime.now() method to display date and time of session.

Example output (from the Eclipse console)

Enter your name: Kevin

Enter "A" for Addition, "S" for Subtraction, "M" for Multiplication, "D" for Division: M

Enter the number of problems you wish to work: 3

What are the low and high numbers you want in your problems?

Enter the low value for your problems: 0

Enter the high value for your problems: 10

10 * 0 = 0

Correct

2 * 3 = 5

Incorrect

8 * 9 = 72

Correct

Session Summary

3 problems, 2 correct

Score is 67, Time is     11 seconds

Session for Kevin was Multiplication on 2020-08-24 at 00:09:40.401

------ Please help me answer the questions below as well. ------

Testing. Describe how you tested this program.

Analysis. Describe the problem including input, processing, primary calculations, and output in your own words.

Design. Describe the major steps for solving the problem.

Solutions

Expert Solution

JAVA PROGRAM ===>

import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;

public class Question {
  
   public static void main(String arg[]) {
       String name;
       Scanner sc = new Scanner(System.in);
       int num,max,min,count=0;
       double num1,num2;
       double ans,result;
       String str ="";
       System.out.print("Enter your name : ");
       name = sc.nextLine();
      
       System.out.println("Enter \"A\" for Addition, \"S\" for Subtraction, \"M\" for Multiplication, \"D\" for Division: M");
       System.out.print("Enter : ");
       char ch = sc.next().charAt(0); // input choice for operation
       System.out.print("Enter the number of problems you wish to work : ");
       num = sc.nextInt();
       System.out.println("What are the low and high numbers you want in your problems?");
       System.out.print("Enter the low value for your problems : ");
       min = sc.nextInt();
       System.out.print("Enter the high value for your problems : ");
       max = sc.nextInt();
       long startTime = System.nanoTime(); // start session for questions
       if(ch == 'A')
       {
           str = "Addition";
           for(int i=0;i<num;i++)
           {
               num1 = (int)(Math.random() * (max - min + 1) + min);
               num2 = (int)(Math.random() * (max - min + 1) + min);
              
               System.out.print((int)num1 +" + "+ (int)num2 +" = ");
               ans = sc.nextDouble();
               if(ans == (num1+num2))
               {
                   count++;
                   System.out.println("Correct");
               }
               else
               {
                   System.out.println("Incorrect");
               }
           }
          
       }
       else if(ch == 'S')
       {
           str = "Subtraction";
           for(int i=0;i<num;i++)
           {
               num1 = (int)(Math.random() * (max - min + 1) + min);
               num2 = (int)(Math.random() * (max - min + 1) + min);
              
               System.out.print((int)num1 +" - "+ (int)num2 +" = ");
               ans = sc.nextDouble();
               if(ans == (num1-num2))
               {
                   count++;
                   System.out.println("Correct");
               }
               else
               {
                   System.out.println("Incorrect");
               }
           }
       }
       else if(ch == 'M')
       {
           str = "Multipication";
           for(int i=0;i<num;i++)
           {
               num1 = (int)(Math.random() * (max - min + 1) + min);
               num2 = (int)(Math.random() * (max - min + 1) + min);
              
               System.out.print((int)num1 +" * "+ (int)num2 +" = ");
               ans = sc.nextDouble();
               if(ans == (num1*num2))
               {
                   count++;
                   System.out.println("Correct");
               }
               else
               {
                   System.out.println("Incorrect");
               }
           }
       }
       else if(ch == 'D')
       {
           str = "Division";
           for(int i=0;i<num;i++)
           {
               num1 = (int)(Math.random() * (max - min + 1) + min);
               num2 = (int)(Math.random() * (max - min + 1) + min);
              
               System.out.print((int)num1 +" / "+ (int)num2 +" = ");
               ans = sc.nextDouble();
              
               result = (num1/num2);
               double result1 = Math.round(result*1000.0)/1000.0;
               if(ans == result1 )
               {
                   count++;
                   System.out.println("Correct "+result1);
               }
               else
               {
                   System.out.println("Incorrect "+result1);
               }
           }
       }
       else
       {
           System.out.println("Wrong Input !");
       }
      
       long endTime = System.nanoTime(); // sessio end for question
      
       System.out.println("");
       System.out.println("Session Summary : ");
       System.out.println(num+" problems,"+count+" correct");
       double avg = (count*1.0/num*1.0)*100;
      
      
      
       long totalTime = endTime - startTime; // calculate time in nanoseconds
       long seconds = TimeUnit.NANOSECONDS.toSeconds(totalTime); // convert time nanoseconds to seconds
      
       System.out.println("Score is "+(Math.round(avg)) +", Time is : "+seconds+" seconds");
       DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); // date
       LocalDateTime now = LocalDateTime.now(); // local time
       System.out.println("Session for "+name+" was "+str+" on "+dtf.format(now));
   }
}

OUTPUT SCREENSHOT ===>


Related Solutions

Design and implement a Java program that creates a GUI that will allow a customer to...
Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor. The customer should be able to order a variety of items which are listed below. The GUI should allow the customer (viaJavaFX UI Controls - text areas, buttons, checkbox, radio button, etc.) to input the following information: Name of the customer First Name Last Name Phone number of the customer Type of food being order...
Need a program in java that creates a random addition math quiz The program should ask...
Need a program in java that creates a random addition math quiz The program should ask the user to enter the following The smallest and largest positive numbers to be used when generating the questions - The total number of questions to be generated per quiz - The total number of the quiz's to create from then the program should generate a random math (Just addition) quiz from what the user entered
Java Proect Project Outcomes Develop a Java program that: • creates a user designed class •...
Java Proect Project Outcomes Develop a Java program that: • creates a user designed class • uses proper design techniques including reading UML Class Diagrams • reads input from the keyboard using a Scanner Object and its methods • uses selection (if and if else) statements • uses iteration (while, do while or for) statements • uses String comparison methods. • follows standard acceptable programming practices. • handles integer overflow errors Prep Readings: Zybooks chapter 1 - 6 1. General...
Write a JAVA application that asks elementary students a set of 10 math problems First ask...
Write a JAVA application that asks elementary students a set of 10 math problems First ask the user for a level and a problem type. You need to validate the level and problem type and loop until the user enters a correct one. There should be 3 levels. Level 1 operands would have values in the range of 0-9, level 2 operands would have values in the range of 0-99, and level 3 operands would have values in the range...
Write a JAVA application that asks elementary students a set of 10 math problems First ask...
Write a JAVA application that asks elementary students a set of 10 math problems First ask the user for a level and a problem type. You need to validate the level and problem type and loop until the user enters a correct one. There should be 3 levels. Level 1 operands would have values in the range of 0-9, level 2 operands would have values in the range of 0-99, and level 3 operands would have values in the range...
Overview: implement the ADT List in Java. This program is meant to the ADT List from...
Overview: implement the ADT List in Java. This program is meant to the ADT List from the ground up In the lecture, we learned how to implement an ADT like the ArrayList you have used in Project 1. With this project, you have the chance to implement an ADT called MyList, which is a simplified replacement for the full-blown ArrayList. Requirements You will implement the MyList ADT according to the following: 1. MyList must implement the List interface. It will...
write a java program to evaluate the highest number input by user, cannot use math class,...
write a java program to evaluate the highest number input by user, cannot use math class, must use overloading . Must compute four computeHighNum methods. Here is what I have. import java.util.Scanner; public class Overload { public static void main(String[] args){ Scanner input = new Scanner(System.in); int number1 = input.nextInt(); int number2 = input.nextInt(); int number3 = input.nextInt();    //int maximum = maximum(number1, number2 ); System.out.printf("Highest integer is ");       // int number1 = input.nextInt(); // int number2 =...
Java Program. Sentinel While Loop Lab Do the following: Prompts the user to enter a grade...
Java Program. Sentinel While Loop Lab Do the following: Prompts the user to enter a grade or a -1 to quit. IF the user entered a -1 THEN Display a message that the User is done entering grades ELSE Count each grade as it is entered. Compute a running total of the grades entered. END IF After the user enters the sentinel of -1, calculate the average of the grades entered. When computing the average, make sure that there is...
Java - Design and implement an application that creates a histogram that allows you to visually...
Java - Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered. Sample...
An elementary principal is interested in determining if pulling 5th and 6th grade students out of...
An elementary principal is interested in determining if pulling 5th and 6th grade students out of class to participate in music classes (e.g., orchestra, band, choir) has a significant impact on their course grades. Twenty students from the two grades miss math class once per week due to music. The average grade for math class among all students is 80%. Do these music students have significantly different grades than the rest of the students (m=80, s=8). Test at the .01...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT