| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Please can someone help me with this it's needs to b coded in c
[/* CH9A02.cpp */
/* Calculates average sales */ #include <stdio.h> #include <conio.h> void main () { /* Description ...... Open input file Display headings Initialise grand total FOR each person Initialise person total FOR each sales figure Read sales Accumulate person total and grand total Calculate and display person average Calculate and display overall average Close input file */ /* const and variable declarations */ const int num_of_sales_people = 5, num_of_sales_figs = 6 ; int person_num, sales_num ; float sales_figure, person_total, person_average, grand_total, overall_average ; FILE *inpfile = fopen ("figures.txt", "r") ; getch () ; } ] this programme should read the text file figures.txt which contains the following info : 40 60 70 70 60 60 30 32 23 34 48 52 59 45 43 95 52 61 55 71 73 42 75 69 20 32 76 56 56 81 the output shud be displayed on screen as follows : SALES FIGURES : person average 1 60.00 2 36.50 3 59.17 4 64.17 5 53.50 overall average is 54.67 |
|
#2
|
||||
|
||||
|
Nice, so what is the problem we can help you with? You already have a program yourself offcourse and you need help with some bug right?
|
|
#3
|
|||
|
|||
|
Help
Ye i need help any ideas. Thanks
|
|
#4
|
|||
|
|||
|
Hi
Do you want me to post what i have done so far and see if you can carry on from there
|
|
#5
|
||||
|
||||
|
Yes that would be good.
__________________
---Official Member Of The Itsacon Fan Club--- ![]() Give a man a fish and he will eat for a day. Teach a man to fish and he will sit in a boat all day drinking beer. |
|
#6
|
|||
|
|||
|
Here's what ive done so far any ideas
[/* CH9A02.cpp */ /* Calculates average sales */ #include <stdio.h> #include <conio.h> void main () { /* Description ...... Open input file Display headings Initialise grand total FOR each person Initialise person total FOR each sales figure Read sales Accumulate person total and grand total Calculate and display person average Calculate and display overall average Close input file */ /* const and variable declarations */ const int num_of_sales_people = 5, num_of_sales_figs = 6 ; int person_num, sales_num ; float sales_figure, person_total, person_average, grand_total, overall_average ; FILE *inpfile = fopen ("CH9A02.txt", "r") ; printf ("SALES FIGURES\n") ; |
|
#7
|
|||
|
|||
|
[/* CH9A02.cpp */
/* Calculates average sales */ #include <stdio.h> #include <conio.h> void main () { /* Description ...... Open input file Display headings Initialise grand total FOR each person Initialise person total FOR each sales figure Read sales Accumulate person total and grand total Calculate and display person average Calculate and display overall average Close input file */ /* const and variable declarations */ const int num_of_sales_people = 5, num_of_sales_figs = 6 ; int person_num, sales_num ; float sales_figure, person_total, person_average, grand_total, overall_average ; FILE *inpfile = fopen ("CH9A02.txt", "r") ; printf ("SALES FIGURES\n") ; for (person_num = 1 ; person_num <= 5 ; ++ person_num) { fscanf (inpfile, "%d" , &person_average) ; printf ("%2d", person_num) ; That's what ive done so far any idea's |
|
#8
|
|||
|
|||
|
Please can sumone help me with this programme, i will be very greatfull Thanks
![]() |
|
#9
|
|||
|
|||
|
I'm not sure people will be happy to help you when you've tried so little!
Just take each string and work out how to extract each number. The rest should be trivial. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Please can someone help me with this it's needs to b coded in c |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|