This is my loop which donates for group number. I am wondering how to calculate the number of donations to find the average for each group.
using the system; Public Sector Total Purchases {Public Stable Zero Main () {Double Total 4 = 0; Double Total 5 = 0; Double Total 6 = 0; Int myint = -1; While (mant! = 0) {string group; Console.light line ("Please enter group number (4, 5, or 6)"); Console.light line ("(to leave 0):"); Group = Console.ReadLine (); Myint = Int32.Parse (group); Switch (Manit) {Case 0: Break; Case 4: Double charity 4; String input string 4; Console Type ("Please enter the contribution amount:"); InputString4 = console Readline (); Donate 4 = convert toDouble (inputString4); Total 4 + = Charity 4; break; Case 5: Dual charity 5; String input string 5; Console Type ("Please enter the contribution amount:"); Input String 5 = console Readline (); Donate 5 = Convert. ToDouble (inputString5); Total 5 + = donation 5; break; Case 6: Double Dan 6; String input string 6; Console Type ("Please enter the contribution amount:"); InputString6 = console Readline (); Donate 6 = Convert. Repeat (input string 6); 6+ = Dan 6; break; Default: console.print line ("wrong grade number.", Mant); break; }} Console. WrightLine ("Grade 4 total {0}", total 4.ToString ("C")); Console.light line ("grade 5 total {0}", total 5.ToString ("C")); Console.light line ("grade 6 total {0}", total 6. toastring ("c"); }} Any help would be appreciated.
using the system; Public Sector Total Purchases {Public Stable Zero Main () {Double Total 4 = 0; Double Total 5 = 0; Double Total 6 = 0; Int nooffinputflight4 = 0; Int numberoffinternetormal5 = 0; Int numberoffinoutphrase 6 = 0; Int myint = -1; While (mant! = 0) {string group; Console.light line ("Please enter group number (4, 5, or 6)"); Console.light line ("(to leave 0):"); Group = Console.ReadLine (); Myint = Int32.Parse (group); Switch (Manit) {Case 0: Break; Case 4: Double charity 4; String input string 4; Console Type ("Please enter the contribution amount:"); InputString4 = console Readline (); Donate 4 = convert toDouble (inputString4); Total 4 + = Charity 4; NumberOfInputForTotal4 ++; break; Case 5: Dual charity 5; String input string 5; Console Type ("Please enter the contribution amount:"); Input String 5 = console Readline (); Donate 5 = Convert. ToDouble (inputString5); Total 5 + = donation 5; NumberOfInputForTotal5 ++; break; Case 6: Double Dan 6; String input string 6; Console Type ("Please enter the contribution amount:"); InputString6 = console Readline (); Donate 6 = Convert. Repeat (input string 6); 6+ = Dan 6; NumberOfInputForTotal6 ++; break; Default: console.print line ("wrong grade number.", Mant); break; }} Console. WrightLine ("Grade 4 total {0}", total 4.ToString ("C")); Console.light line ("grade 5 total {0}", total 5.ToString ("C")); Console.light line ("grade 6 total {0}", total 6. toastring ("c"); Console.light line ("grade 4 is average {0}" (total 4 / numberoffinputfalic4). Ostring ("c"); Console.light line ("grade 5 is average {0}" (total 5 / numberofoffinputformatel5). Ostring ("c"); Console.light line ("grade 6 average {0}", (total 6 / numberoffinputformatel 6). Ostring ("c"); }} As you can see, there are 3 additional variables (one for each group) that can be used to detect the number of inputs provided. Using it, you can split the total number in each group for each group of each group.
Comments
Post a Comment