Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 12th, 2014, 08:36 AM
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
  #2 (permalink)  
Old April 4th, 2015, 03:13 PM
RobinHoney
Guest
 
Posts: n/a
Default

anyone's knows what is programming of Armstrong number
Reply With Quote
  #3 (permalink)  
Old April 9th, 2015, 12:44 PM
Registered User
 
Join Date: Apr 2015
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am interested to learn C+++ programming. Can someone tell me what should I do in order to learing C++ programming?
Reply With Quote









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.