making a choice
Apr 24, 2014 at 2:18am UTC
im writing a source for a choice program that does the commands in its function and the program runs fine. the only sections not working is :
Above Average # 5-2
Two Die Simulation # 5-6
Olympic Judging # 5-8
and for the Olympic Judging # 5-8 it is supposed to do the average of the remaining four score and the highest and lowest scores are not include in the average. i have written the code but not sure it is right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
// Function prototypes
void Number(); // Number Stack Different # 4-4
void RightTriangle(); // Right Triangle # 4-6
void AboveAverage(); // Above Average # 5-2
void TwoDieSimulation(); // Two Die Simulation # 5-6
void AccessGranted(); // Access Granted # 5-7
void OlympicJudging(); // Olympic Judging # 5-8
void Func7();
int main()
{
int Choice;
do {
cout << endl <<"\t\tTeam Shuriken" << endl <<endl;
cout << " 1. Number Stack Diiferent " << endl;
cout << " 2. Right Triangle " << endl;
cout << " 3. Above Average " << endl; // not working properly !!CHECK!!
cout << " 4. Two Die Simulation " << endl;
cout << " 5. Access Granted " << endl;
cout << " 6. Olympic Judging " << endl;
cout << " 7. Func7 " << endl;
cout << " 8. Quit the Program" << endl << endl;
cout << "Enter number 1 - 8 for your Choice: " ;
cin >> Choice;
if (Choice==1)Number();
else if (Choice==2)RightTriangle();
else if (Choice==3)AboveAverage();
else if (Choice==4)TwoDieSimulation();
else if (Choice==5)AccessGranted();
else if (Choice==6)OlympicJudging();
else if (Choice==7)Func7();
}while (Choice != 8);
system("cls" );
cout << " Thank You " << endl;
system("PAUSE" );
return 0;
}
void Number() // Number Stack Different
{
int SMB;
for (int num = 1; num <= 9; num++){
for (int num1 = 1; num1 <= num; num1++){
SMB = num1;
cout << SMB;
}
cout <<" " << endl;
}
}
void RightTriangle() // Right Triangle
{
for (int LineCount = 1; LineCount <= 10; LineCount++){
for (int SpaceCount = 10 - LineCount; SpaceCount > 0; SpaceCount--){
cout <<" " ;
}
for (int CircleCount = 1; CircleCount < LineCount; CircleCount++){
cout << "o" ;
}
cout << endl;
}
}
void AboveAverage() // Above Average
{
double numbers [5], average = 0;
int i, count = 0;
for (i = 0; i < 6; i++){
cout << "Please type a value for LIST: " ;
cin >> numbers[i];
}
average = numbers[i];
average = average / 5;
cout <<"The average is: " << average << endl;
for (i = 0 ; i < 6; i++){
if (numbers[i] > average)
count++;
cout << count <<"The following numbers are greater than the average: \n" << endl;
cout << numbers[i];
}
}
void TwoDieSimulation() //Two Die Simulation
{
int counters [12];
double diePercentage;
int rolltomake, dieValue;
cout <<"Please type a value for ROLLTOMAKE: " ;
cin >> rolltomake;
for (int i = 1; i <= rolltomake; i++){
dieValue = rand() % 12 + 1;
counters[dieValue] = counters[dieValue] + 1;
}
for (int k = 1; k <= 12; k++){
cout <<"The value " << k << "was rolled " << counters[k] << " times " ;
diePercentage = (counters[k] * 100) / rolltomake;
cout << diePercentage << endl;
}
cout <<"Below are the results in histogram form: \n" ;
for (int x = 1; x <= 12; x++){
cout << x << " : " ;
for (int n = 1; n <= counters[n]; n++){
cout <<"o" ;
}
cout << endl;
}
}
void AccessGranted() // Access Granted
{
string inputUser, inputPass;
int foundFlag, k;
string userName [10];
string passWord [10];
for (k = 1; k <= 2; k++){
cout <<"\nEnter the Username: " ;
cin >> userName[k];
cout <<"Enter the Password: " ;
cin >> passWord[k];}
cout <<"Input User: " ;
cin >> inputUser;
foundFlag = false ;
for (k = 1; k <= 2; k++){
if (inputUser == userName[k])
foundFlag = true ;
cout <<"Input Pass: " ;
cin >> inputPass;
if (inputPass == passWord[k])
cout <<"Access granted." ;
else
cout <<"Username and password do not match." ;
}
if (foundFlag = false )
cout <<"Username not Found" ;
}
void OlympicJudging() // Olympic Judging
{
double numbers [6], average;
int i, count = 0;
int highScore, lowScore, highest, lowest;
for (i = 0; i < 6; i++){
cout << "Please type a value for scores: " ;
cin >> numbers[i];
}
highScore = numbers[0];
lowScore = numbers[0];
for (int x = 0 ; x < i ; x++){
if (numbers [i] > highScore){
highest = numbers[i];
}
if (numbers[i] < lowScore){
lowest = numbers[i];
}
if (numbers[i] != highest)
if (numbers[i] != lowest)
average = numbers[i] / 4;
}
cout <<"\nHighest Score : " << highest << endl;
cout <<"Lowest Score : " << lowest << endl;
cout <<"Olympic Averge : " << average << endl;
}
void Func7()
{
cout << "Yet to be completes -- Member was Absent" << endl;
}
Last edited on Apr 24, 2014 at 2:19am UTC
Topic archived. No new replies allowed.