Lab6 2
Lab6 2
5
Exercise 1:
PI PI
RATE RATE
Circumference
Exercise 2&3:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
// PARASPREET SINGH
int main()
{
cout << fixed << showpoint << setprecision(2);
float radius = 12;
{
float area;
findArea(radius , area);
{
float radius = 10;
float circumference;
findCircumference(radius, circumference);
cout << "Main function after all the calls" << endl;
cout << "PI, RATE and radius are active here" << endl << endl;
return 0;
}
12
10
Exercise 5:
Output;
LAB 6.6
Exercise 1:
Expected Results:
EXERCISE 2:
#include <iostream>
#include <iomanip>
using namespace std;
// PARASPREET SINGH
void normalizeMoney(float& dollars, int cents = 150);
int main()
{
int cents;
float dollars;
cents = 95;
cout << "\n We will now add 95 cents to our dollar total\n";
normalizeMoney(dollars, cents);
cout << "Converting cents to dollars resulted in " << dollars << " dollars\n";
cout << "\n We will now add 193 cents to our dollar total\n";
normalizeMoney(dollars, 193 );
cout << "Converting cents to dollars resulted in " << dollars << " dollars\n";
cout << "\n We will now add the default value to our dollar total\n";
normalizeMoney(dollars);
cout << "Converting cents to dollars resulted in " << dollars << " dollars\n";
return 0;
}
cout << "We have added another $" << dollars << " to our total" << endl;
cout << "Our total so far is $" << sum << endl;
cout << "The value of our local variable total is $" << total << endl;
}
OUTPUT:
LAB 6.7
Exercise 1:
If you will run the program like this incompletely, it will allow you to input the amount
but it will not show any result.
Exercise 2:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
// PARASPREET SINGH
int main()
{
float dollars;
float euros;
float pesos;
float yen;
cout << fixed << showpoint << setprecision(2);
cout << "Please input the amount of American Dollars you want converted "
<< endl;
cout << "to euros and pesos" << endl;
cin >> dollars;
cout<<"$"<< dollars <<" is converted to " << pesos << " pesos and " << euros
<< " euros \n ";// Fill in the code to output the value of those dollars converted
to both euros
// and pesos
cout << "Please input the amount of American Dollars you want converted\n";
cout << "to euros, pesos and yen" << endl;
cin >> dollars;
cout<<"$ "<< dollars <<" is converted to " << yen<< " yen" <<" and " << euros
<< " euros and "<< pesos <<" pesos \n";// Fill in the code to output the value of
those dollars converted to euros,
// pesos and yen
cout << "Please input the amount of American Dollars you want converted\n";
cout << "to yen" << endl;
cin >> dollars;
cout<<"$ "<< dollars <<" is converted to " << yen<< " yen" << endl;// Fill in
the code to output the value of those dollars converted to yen
cout << "Please input the amount of American Dollars you want converted\n";
cout << " to euros" << endl;
cin >> dollars;
cout<<"$ "<< dollars <<" is converted to " << euros << " euros \n ";// Fill in
the code to output the value of those dollars converted to euros
cout << "Please input the amount of American Dollars you want converted\n";
cout << " to pesos " << endl;
cin >> dollars;
cout<<"$ "<< dollars <<" is converted to " << pesos << " pesos \n ";// Fill in
the code to output the value of those dollars converted to pesos
return 0;
}
// All of the functions are stubs that just serve to test the functions
// Replace with code that will cause the functions to execute properly
// **************************************************************************
// convertMulti
//
// task: This function takes a dollar value and converts it to euros
// and pesos
// data in: dollars
// data out: euros and pesos
//
// *************************************************************************
// ************************************************************************
// convertMulti
//
// task: This function takes a dollar value and converts it to euros
// pesos and yen
// data in: dollars
// data out: euros pesos yen
//
// ***********************************************************************
// ****************************************************************************
// convertToYen
//
// task: This function takes a dollar value and converts it to yen
// data in: dollars
// data returned: yen
//
// ***************************************************************************
// ****************************************************************************
// convertToEuros
//
// task: This function takes a dollar value and converts it to euros
// data in: dollars
// data returned: euros
//
// ****************************************************************************
// *****************************************************************************
// convertToPesos
//
// task: This function takes a dollar value and converts it to pesos
// data in: dollars
// data returned: pesos
//
// ****************************************************************************
Output: