Finding Means with arrays - c++

I got the assignment and the numbers to create a program which asks
You are to write a C++ program that will prompt for and re ad in the
Math and Verbal SAT scores for a sample population of students and
then determine the mean Math SAT score, the mean Verbal SAT score, the
standard deviation for the Math SAT scores and the standard deviation
for the Verbal SAT scores respectively.
The part that is confusing me is I am not sure if the program is asking me to input the scores given right into the code or to make a function or whatever to input them in as a user.
This another part of the assignment which may be pertinent.
Read the Math and Verbal SAT scores from the keyboard into a two
dimensional array for storage. The array should have 10rows and two
columns one for the math SAT score and the second for the verbal SAT
score.
Sorry for asking such an easy question my brain is fried and I am in over my head. I am going in for help tomorrow but I need to have more of a code together because the project is due for Wednesday.

write a C++ program that will prompt for and re ad in the Math and Verbal SAT scores
You're expected to take them as input from the user.
i.e. don't hardcode them, take them as keyboard input.

Related

C++ Is there any way to classify parts of a text file then use them seperately?

I am currently trying to do my college homework, we are studying file streams and vectors in C++ right now, our task is long but I will just try to explain my main problem:
We need to read multiple text files and get information and store them in vectors,
anyways, in our first text file, there are parts we need to read like this:
HOMEWORK
00011234 84
00012341 90
00012481 100
MIDTERM
00011234 55
00012341 99
00012481 50
(student Id, grade)
etc... In our task, we need to get 10% of homework grade, 20% of midterm grade and 30% of final grade, and then take the sum of grades related with student id's.
My question is: is there any way to read by iteration or group these informations, and use them to take related percentages?
(btw we didn't learn classes/structs/pointers yet, so it's forbidden to use them in our task, just vectors, fstream, sstream, string libraries.)
Also, there are multiple homework grades for a student, or only 1 homework grade etc. (We need to take percentages and sum all grades of that student)
I don't know if there is a way to use getline function until a specific line.
There are many ways of going about that, but a simple one is to use the break keyword to exit out of a loop when a certain condition is met.
std::ifstream file_stream ("file.text");
std::string line_text;
while(getline(file_stream, line_text)) {
if(line_text == "MIDTERM") { // or whatever other test makes sense for your situation.
// This will make the program skip to immediately after the loop.
break;
}
// Handle otherwise
}

aws certified developer exam result

I recently did an AWS exam (certified developer-associate). As you may know, the scoring range is between 100 to 1000, and the minimum score to pass the exam is 720.
Unfortunately I scored 615 points, which means I did not pass the exam. AWS e-mailed me to inform my score. In this e-mail there is no no transcription/percentage of each part of the test. This means I am not able to see on which topics I need to study more to pass my next exam.
Is there any person here who took this exam? If so, could you please tell me how I can understand how many questions I needed to answer more to pass this exam?
The total exam consists of 65 questions. With a passing rate of 72% (720/1000), this amounts to approximately 47 questions (65 * 0.72).
A score of 615 means you had about 40 questions right (65 * 0.615). This means you had to correctly answer about 7 questions more to pass the exam. This is an assumption, as AWS may change the passing rate over time.
615 is not too bad, I would suggest you take some more practice exams and focus on the topics that need more attention according to those tests. To be certain I would make the real exam if you score about 80% on practice exams.

Allowing a test to run again C++

I'm new to Stack Overflow and would just like to thank all the people that have unknowingly helped me so far. Anyhow, I'm currently writing the pseudocode for a program in which multiplication problems are generated for the user to answer. My professor wants this program to run until the user enters a sentinel value that would stop asking the user questions, and then display a report of how many questions they correctly answered and so forth.
All of that makes sense to me, and I'd probably be able to code most of that right now without struggling much. However, at the end of the direction sheet, it says "Your program should then repeat the process for another test taker". I'm not entirely sure how I'd go about doing that, since I have a 'while loop' running until the user terminates the program. The pseudocode is as follows:
BEGIN Lab 4 - Multiplication Program
Mult_Num_1 = Random positive single digit number
Mult_Num_2 = Random positive single digit number
Calculate the product
Display the multiplication problem, and sentinel value to quit
User inputs an answer
WHILE ( Answer != QUIT )
IF ( Answer == Product )
Inform user they are correct
Add 1 to Correct_Counter
Add 1 to Question_Counter
ELSE
Inform the user they are incorrect
Display the correct answer
Add 1 to Question_Counter
END IF
Calculate percentage of correct questions
Clear screen
Mult_Num_1 = Random positive single digit number
Mult_Num_2 = Random positive single digit number
Calculate the product
Display the multiplication problem, and sentinel value to quit
User inputs an answer
END WHILE
Display test report
END Lab 4 - Multiplication Program
I'd assume something needs to go after displaying the test report? I'm not entirely sure, but any help would greatly be appreciated. Thank you for taking your time to look over this!

Stuck on a program creation assignment utilising Visual C++,

I am Brand New to programming, Ienter code here have an assignment to do, based on this image and question here, " A local electronics store allows items to be purchased on hire purchase. The hire purchase option
requires a deposit of one fifth of the cash price. There is an interest charge of 10% on the
balance.
Consider the following example: A customer wishes to purchase a Dell Inspiron 15-inch laptop,
with an i5 processor and 8 GB RAM, for $3500. The item code is 12345 and the customer
chooses to pay via two years of hire purchase.
The program operates as follows:
Write a program, HirePurchase, which prints the invoice for an item on hire purchase as
detailed above. The program prompts for the item code, cash price and the number of years on hire
purchase. enter image description here
I have begun but every time I try to run the program only a piece of it presents itself on screen. I'm very sorry if this seems basic but I'm interested in programming.
#include <iostream>
using namespace std;
int main () {
int NumberMonthHirePurchase,ItemCode,NumberYearHirePurchase;
double CashPrice,Deposit,MonthlyInstall,NewbalanceOne, NewBalanceTwo;
cout<<"Please enter the Item Code:2768N3496YHG";
cin>>ItemCode;
cout<<"Please enter the cash price of the item:6,264";
cin>>CashPrice;
cout<<"Please enter the Number of Years Hire Purchase:1";
cin>>NumberYearHirePurchase;
cout<<endl;
cout<<"item details"<<endl;
cout<<"Item code:2768N3496YHG"<<ItemCode<<endl;
return 0;
}
this is what I have so far but only "please enter the item code" is appearing and nothing else. I don't know if it's because I am doing something wrong, can someone please assist, would be greatly appreciated.
The variable ItemCode is an int. That means cin>>ItemCode will read only 2768 from the input. The rest of the input, N3496YHG, will be left in the input buffer for the remaining input to read.
However, since the next input is to read a floating point value, and N3496YHG is not a valid floating point value, nothing will be read and an error flag will be set on the input stream.
Since the error flag is now set on the stream, the third attempt to read something (the integer for NumberYearHirePurchase) will not do anything at all.
To solve this, the ItemCode should be a string, using std::string.
Also note that input of floating-point values doesn't have to use the comma , as decimal separator. It depends on the settings of your computer.
Of course, the above is only valid if you actually try to input something. If you don't input anything, the program will appear to stand still as it patiently waits for your input.

Trouble calculating correct decimal digits

I am trying to create a program that will do some simple calculations, but am having trouble with the program not doing the correct math, or placing the decimal correctly, or something. Some other people I asked cannot figure it out either.
Here is the code: http://pastie.org/887352
When you enter the following data:
Weekly Wage: 500
Raise: 3
Years Employed: 8
It outputs the following data:
Year Annual Salary
1 $26000.00
2 $26780.00
3 $27560.00
4 $28340.00
5 $29120.00
6 $29900.00
7 $30680.00
8 $31460.00
And it should be outputting:
Year Annual Salary
1 $26000.00
2 $26780.00
3 $27583.40
4 $28410.90
5 $29263.23
6 $30141.13
7 $31045.36
8 $31976.72
Here is the full description of the task:
8.17 ( Pay Raise Calculator Application) Develop an application that computes the amount of money an employee makes each year over a user- specified number of years. Assume the employee receives a pay raise once every year. The user specifies in the application the initial weekly salary, the amount of the raise (in percent per year) and the number of years for which the amounts earned will be calculated. The application should run as shown in Fig. 8.22. in your text. (fig 8.22 is the output i posted above as what my program should be posting)
Opening the template source code file. Open the PayRaise.cpp file in your text editor or IDE.
Defining variables and prompting the user for input. To store the raise percentage and years of employment that the user inputs, define int variables rate and years, in main after line 12. Also define double variable wage to store the user’s annual wage. Then, insert statements that prompt the user for the raise percentage, years of employment and starting weekly wage. Store the values typed at the keyboard in the rate, years and wage variables, respectively. To find the annual wage, multiply the new wage by 52 (the number of weeks per year) and store the result in wage.
Displaying a table header and formatting output. Use the left and setw stream manipulators to display a table header as shown in Fig. 8.22 in your text. The first column should be six characters wide. Then use the fixed and setprecision stream manipulators to format floating- point values with two positions to the left of the decimal point.
Writing a for statement header. Insert a for statement. Before the first semicolon in the for statement header, define and initialize the variable counter to 1. Before the second semicolon, enter a loop- continuation condition that will cause the for statement to loop until counter has reached the number of years entered. After the second semicolon, enter the increment of counter so that the for statement executes once for each number of years.
Calculating the pay raise. In the body of the for statement, display the value of counter in the first column and the value of wage in the second column. Then calculate the new weekly wage for the following year, and store the resulting value in the wage variable. To do this, add 1 to the percentage increase (be sure to divide the percentage by 100.0 ) and multiply the result by the current value in wage.
Save, compile and run the application. Input a raise percentage and a number of years for the wage increase. View the results to ensure that the correct years are displayed and that the future wage results are correct.
Close the Command Prompt window.
We can not figure it out! Any help would be greatly appreciated, thanks!
Do not store money as floating point. This will end only in tears. Store money as an integral number of cents.
The reason for this is that floating point math on a computer is necessarily inexact. You know that 0.40 / 2 = 0.20, but it's entirely possible that the computer will say it is 0.19999999999999, and that is not an error. The internal representation of floating point numbers makes it impossible for a computer to exactly represent some fractions, much like you cannot write out an exact decimal representation of 1/3 (without an infinite amount of paper).
When you are dealing with numbers that have fractional parts and for which inexactness is not acceptable (e.g. money), you must compute using fixed-point math. In general, you might use a fixed point library, but for an assignment like this, if you're not allowed to do so, an int that stores a number of pennies will do just fine, so long as you understand how integer division works. You will have to write more math code and account for the rounding yourself, though. But that's what you want. You want absolute control over rounding.
I changed your for loop to this:
cout << (i+1) << " $" << wage*52 << "\n";
wage = wage * (1+(raise/100.0));
And it did worked!. I see you didn't understand the language of the problem.
I think that the intention is to receive a 3% raise each year, but you are actually only adding 3% of the starting salary ($780 in this case) each year. You may want to explore modifying the wage value on each pass in the loop (I won't present a solution as I suspect that this is a homework problem, yes?).
The best way to catch this sort of problem is to run it in a debugger and step through each line looking for when the results don't match your expectations. It's usually pretty easy at that point to figure out where your logic went astray.
Your problem is that your program ignores compounding. You are calculating the dollar value of the raise once, and using that for each increase. Once you get your first raise, the value of your second raise needs to be calculated based on your new wage, not your original wage.