Thread: Need your help
View Single Post
  #1 (permalink)  
Old June 12th, 2014, 08:36 AM
paulbaah paulbaah is offline
Registered User
 
Join Date: Jun 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need your help

Am creating a menu - driven application that accepts amount outstanding for 10 customers and display the following'

1. the max. amount outstanding
2. the min. amount outstanding
3. the average amount outstandaing
4. the number of customers whose amount outstanding is greater than zero.
5. the amount outstanding in ascending and descending order.

I came up with this codes and am having a terrible time debugging the rest of the bugs. Can you offer your help?
Thanks,

#include<iostream>
//#include<stdlib>
using namespace std;

float amountOS[10];

void acceptArrayList();
void displayArray();
void displayArray(float creditLimit);
float maxAmount();
float minAmount();
float avgAmount();
void sortArray(char sortType);

int main()

{
int choice=0;
float limit=0;
//char system();
acceptArrayList();

do
{
system("clear");

cout << "Main Menu" << endl;
cout << "***********";
cout << "\n\n\n\n\n\n";


cout << "1. Maximun Amount OS" << endl;
cout << "2. Mininum Amount OS" << endl;
cout << "3. Average Of Amounts OS" << endl;
cout << "4. Amount Greater Than Limit" << endl;
cout << "5. Sort OS Amount - Ascending" << endl;
cout << "6. Sort OS Amount - Descending" << endl;
cout << "7. End Program !!" << endl;


cout << "\n\n\n\n\n\n\n" ;
cout << "Enter your Choice: ";
cin >> choice;


switch(choice)
{
case 1:
system("clear");
displayArray();
cout << "\n\n\n\n";
cout << "The Maximun Amount OS is: " << maxAmount() << endl;
break;

case 2:
system("clear");
displayArray();
cout << "\n\n\n\n";
cout << "The Minimun Amount OS is: " << minAmount() << endl;
break;

case 3:
system("clear");
displayArray();
cout << "\n\n\n\n: ";
cout << "The Average Amount OS is: " << avgAmount() << endl;
break;

case 4:
system("clear");
displayArray();
cout << "\n\n\n\n: ";
cout << "Enter The Limit Amount:";
cin>>limit;
displayArray(limit);
break;

case 5:
system("clear");
displayArray();
cout << "\n\n\n\n: ";
sortArray('a');
displayArray();
break;

case 6:

system("clear");
displayArray();
cout << "\n\n\n\n: ";
sortArray('c');
displayArray();
break;

case 7:
break;

default:
cout << 'invalid Choice Entered............. ' << endl;
break;
}

system('sleep 8');

} while(choice != 7);
}
void acceptArrayList()
{
for(int i=0; i<10; i++)
cout << "Enter Value For Array Index: " << !+1 << ': ';
cin >> amountOS[] << ' ';

}
}
void displayArray()
{
for(int i=0; i<10; i++)
cout << "amountOS[]<<" ': ';
cout << "\n\n\n\n: ";
}

void displayArray(float creditLimit)
{
cout << "The Amounts OS greater than:" << creditLimit << "are: " << endl;
cout << "\n\n\n" <<endl;
for(int i=0; i<10; i++)
{
if(amountOS[i]> creditLimit)
{
cout << amountOS[i]<< '';
}
}
cout << "\n\n\n";
}

float maxAmount()
{
float maxi = amountOS[0];
for(int i = 1; i <10; i++)
{
if(amountOS[i] > maxi)
{
maxi=amountOS[i];
}
}
return maxi
}
float minAmountOS[0];

for(int i = 1; i < 10; i++)
{
if(amountOS[i] < mini)
{
mini=amountOS[i];
}
}
return mini;

{

float avgAmount()
{
float avg - 0;
for(int i-0; i,10; i++)
{
avg = avg + amountOS[1];
}
avg/=i; //same as avg=avg/i
return avg;
}
void sortArray(char sortType)
{
float temp;

for(int outer=0; outer<10; outer++)
{
for(int inner=outer; inner<10; inner++)
{
if ( ((amountOS[inner]< amountOS[outer])
&& sortType=='a'
|| ((amountOS[inner]> amountOS[outer]))
&& sortType =='c'
(
temp=amountOS[inner];
amountOS[inner]=amountOS[outer];
amountOS[outer]=temp;
}
}
}
}
Reply With Quote