I've been asked to do an assignment that does the following
A) input each test result (1 2 or 2), display the program display "enter result" each time the program requests another result.
B)count the number of test results of each type
C) display a summary on screen of the test result indicating the number of student who passed or failed
D)if more than 10 passed print the message "bonus to the instructor"
So far what I've managed to do, with help, is this:
#include <stdio.h>
int main ()
{
int arr[15]; //declares integer array with 15 elements
for (int i = 0; i < 15; i++) // i starts at 0, and will increase by 1 each time the loop runs
// once i reaches 15, the loop will stop executing, because arr[15] is outside of our array
{
arr[i] = (i + 1) * 100; // In your test program you assign 100 to element 0,
// 200 to element 1, and so on
// this statement takes the element number (i), adds 1, then multiplies by 100 to get 100 for element 0, 200 for element 1, etc
}
char str[] = "c program"; // this is unchanged
for (int i = 0; i < 15; i++) // same loop as used before
{
printf("%d: %d\n", i+1, arr[i]); //we want to print 2 numbers, the element number + 1 and the value in the array at that element
//so we do i+1 to get "1" to print for the value in the 0th element
}
printf("string: %s\n", str); // this is unchanged
return 0;
}
I believe it covers part "A" of the assignment, could someone direct me and give help with the rest? thanks
Start with your editor, first, whether that is notepad or VI or another, and type in your requirements.
A) input each test result (1 2 or 2), display the program display "enter result" each time the program requests another result.
B)count the number of test results of each type
C) display a summary on screen of the test result indicating the number of student who passed or failed
D)if more than 10 passed print the message "bonus to the instructor"
Main()
{
(Input_Result) //#1
(Count_Results) //#2
(Display_Results) //#3
(Calculate_Bonus) //#4
(More_Exit) // ask user to do more or eXit. // #5
}
Continue to add detail to each step until each step describes what it is suppose to accomplish.
Once your steps are fairly well detailed - and this may take a few hours to a few days depending on your program, then you can go on to think about your variables.
What variables are for TEMP usage, which ones will be passed & returned.
Think about what type vars you'll need ( INT, Double,Float,char)
and remember to use var names that are going to be useful to you and others who may have to read / debug this code a month or so from today.
So don't var names like:
a,b,c,,i,j,k,x,y,z,
or ones that sound close to reserved words like:
temp , time, this, that, amt, rtn
int i_calc_pct;
double d_baseball_avg;
float f_bank_rtn_rate;
int a_result_array;
Sixty percent of your development time should be spent on design.
15% will then be for fixing bugs in the code.
Once you have a planned out design, in, say notepad, or VI or the editor of your choice, then you can copy it into your IDE ( or what ever you are using to compile & link your code) and try it.