Hey guys im trying to work on this assignment i have. I am new to programming and this is my third assignment. Any help would be appreciated. Im not sure if im on the right track or not. here is what i have to do:
allow the user to enter a numeric answer to math problem and display their average score. The user will be allowed to answer as many math problems as they choose. After each entry we will display the current average score. The difference between the while loop and the do loop is the while loop tests a condition before running its code block where the do loop will execute its code block and then test a condition. Hence the names of pre-test loop for the while loop and post-test loop for the do loop. Since the do loop is a post-test loop, it will always execute its code block one time at a bare minimum.
these are the steps im trying to follow:
Inside the Main method block of code we are going to create a do loop. The advantage of a do loop is that it will always execute one time. In this application we will use that advantage to repeat several steps. The following steps are what we want to repeat:
1)Clear the console Display window. (This will keep the display from getting cluttered)
2)Use random object to get/store two random numbers for a math problem.
3)Randomly decide which math operator to use (+-*/)and store the symbol.
4)Display an application header and the math problem formatted.
5)Get the answer from the user and store it in a variable(i.e.“input”).
6)Convert variable(input)from a string to a double or integer.
7)Based on the math symbol calculate the correct answer using random numbers.
8)If user entry matches correct answer,add question point value to points earned total.
9)Add the question point value to the points possible total.
10)Display message with points earned, possible, and the average (earned/possible).
11)Display a message asking the user if they want to quit or get a new math problem.
12)Pause display and get the user response of quit or continue.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MathProblems
{
class Program
{
static void Main(string[] args)
{
string input;
double totalPoints = 0;
double userEarnedPoints = 0;
double average = 0;
int number1 = 0;
int number2 = 0;
int operators = 0;
int answer = 0;
double correctAnswer = 0;
int mathProblem = 0;
do
{
Console.Clear();
Random number = new Random();
number1 = number.Next(1, 31);
number2 = number.Next(1, 31);
operators = number.Next(1, 5); // 1 = add, 2 = minus, 3 = multiply, 4 = divide
Console.WriteLine("\tMath Problems\n");
switch (operators)
{
case 1:
answer = number1 + number2;
break;
case 2:
answer = number1 - number2;
break;
case 3:
answer = number1 * number2;
break;
case 4:
answer = number1 / number2;
break;
default:
break;
}
//if (operators == 1)
//{
// Console.WriteLine("{0} + {1} = ", number1, number2);
//}
//else if (operators == 2)
//{
// Console.WriteLine("{0} - {1} = ", number1, number2);
//}
//else if (operators == 3)
//{
// Console.WriteLine("{0} * {1} = ", number1, number2);
//}
//else if (operators == 4)
//{
// Console.WriteLine("{0} / {1} = ", number1, number2);
//}
//break;
} while (true);
Console.ReadLine();