Question

C++ programming question will upvote

A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circu

Enter the radius of the circle: [3.5] A circle of radius 3.5 has an area of: 38.4845 and a circumference of: 21.9911 Press an

void printDescription() I/ The function heading 1 cout << This program takes two numbers (payRate &hours)<endl; cout << an

Esenise : Fill in the code (places n bold) and note that the function pa function where those values are printed. Both gross

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have done both this problems. I hope that you wanted it.if you need further help please let me know. I have added comments where it necessary. If you still have problem please let me know by leaving comments.

Program for area calculation------------------------------------

#include<iostream>
using namespace std;
/*Function prototypes*/
double getRadius();
double findArea(double);
double findCircumference(double);


int main(){
   double radius;
   double area;
   double circumference;
  
   radius=getRadius(); /*calling getradius function which takes input from user*/
  
  
   area=findArea(radius);/*calling find area function which calculate area of circle*/
   circumference=findCircumference(radius);/*calling findcircumference function which calclate circumference*/
  
   cout<<"A circle of radius "<<radius<<" has area of: "<<area<<endl;/*endl for new line*/
   cout<<"and a circumference of: "<<circumference<<endl;
  
   system("PAUSE");
   return 0;
}
double getRadius(){/*radius has double data type thats why return type should be double*/
   double radius;/*local radius variale which hold the value from user and it returns a valule to main progrm*/
   cout<<"Enter the Radius of Circle: ";
   cin>>radius;/*Reading input from user*/
   return radius;/*Returning radius to main program*/
}

double findArea(double radius){ /*findArea function takes parameter radius and calculate area and reutrun value to main function, over here return type is double because area's data type is double*/
   double area; /*local area variale which hold the value of area(calculation) and it returns a valule to main progrm*/
    area=3.14159*radius*radius;/*calculating area*/
   return area;/*Returning area to main function*/
}

double findCircumference(double radius){
   double circumference; /*local circumference variale which hold the value of circumference(calculation) and it returns a valule to main progrm*/
   circumference=2*3.14159*radius; /*calculating circumference*/
   return circumference; /*returning circumference to main program*/
  
}


Program for net pay-----------------

#include<iostream>
#include<iomanip>
using namespace std;

void printDescription();
void computePaycheck(float,int,float&,float&);

int main(){
   float payRate;
   float grossPay;
   float netPay;
   int hours;
   cout<<setprecision(2)<<fixed;/*to represent floating point number upto 2 decimal point with fixed notation*/
   cout<<"Welcome to the PayRoll Program"<<endl;
  
   printDescription();
  
   cout<<"Please input the pay per hour"<<endl;
   cin>>payRate; /*Reading input payrate*/
   cout<<endl<<"Please input the number of hours worked"<<endl;
   cin>>hours;/*Reading input hours*/
   cout<<endl<<endl;
   computePaycheck(payRate,hours,grossPay,netPay);/*calling compute paycheck in which two parameter payrate and hours are passed by value while gross pay and netpay variale are pass by referance(or in aother words we are passing address of grossPay and nrtpay variable hence any change made in this variable in called function reflacted in main)*/
   cout<<"The gross pay is: $"<<grossPay<<endl;/*printing gross pay*/
   cout<<"The netpay is: $"<<netPay<<endl;/*printing net pay*/
  
  
  
}
void printDescription(){/*Just display function*/
   cout<<"***************************************************************"<<endl<<endl;
   cout<<"This program takes two numbers (Payrate & hours )"<<endl;
   cout<<"and multiplies them to et gross pay"<<endl;
   cout<<"it than calculate net pay by substracting 15%"<<endl;
   cout<<"***************************************************************"<<endl<<endl;
}
void computePaycheck(float rate,int hours,float& gross, float& net){/*function defination in which rate=payrate and hours=hours, while gross is alias to Grosspay it looks like (float& gross= grossapay hence gross and grossPay referes to same address hance any change made into gross reflacted in grossPay, simmilary for net*/
   gross=rate*hours;/*calculating gross pay by multiplying rate/hours and hours*/
   net=0.85*gross;/*net pay is 15% less what he/she earned hence (1-0.15=0.85) and multiplying with gross pay*/
}

i +-5.11 nDocumentstareaandcic.cpp-(Executing)- Dev-C View Project Execute Tools AStyle Window Help ch TOM-GCC 4.9.2 64-bit Rsersladmin Documents callvalue.cpp- [Executing)-Dev-C+ 5.11 dit Search View Project Execute Tools AStyle Window Help 64-bit R

Add a comment
Know the answer?
Add Answer to:
A) One of the problems that have been discussed in the class is to write a simple C++ program to ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A) One of the problems that have been discussed in the class is to write a...

    A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...

  • Exercise 2: There can be several constructors as long as they differ in number of parameters...

    Exercise 2: There can be several constructors as long as they differ in number of parameters or data type. Alter the program so that the user can enter just the radius, the radius and the center, or nothing at the time the object is defined. Whatever the user does NOT include (radius or center) must be initialized somewhere. There is no setRadius function and there will no longer be a setCenter function. You can continue to assume that the default...

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

  • modify sample code from example two to calculate the surface area and volume of a sphere...

    modify sample code from example two to calculate the surface area and volume of a sphere givin the radius int main() Example 2 Introduction to structures and passing the structure variables as arguments into functions. 1. A structure is created with circle related variables. 2. Two functions are created related to circle calculations. 3. This example passes structure variables from the main function to the message Circle function 4. The message Circle function converts the structure variables into regular double...

  • c++ Please help! i keep getting an error message. I think my main problem is not...

    c++ Please help! i keep getting an error message. I think my main problem is not understanding the circle calculations function and how both the area and the circumference is returned from the function. I know & needs to be used, but I am unsure how to use it. Copy the following code and run it. You should break it into the following 3 functions getValidinput - which asks the user to enter the radius and then make sure that...

  • #include <iostream> using namespace std; class Circle{ // private member variable named radius private: double radius;...

    #include <iostream> using namespace std; class Circle{ // private member variable named radius private: double radius; // get function for radius public: double getRadius(){ return radius; } // set function for radius void setRadius(double rad){ radius=rad; } // returning area = 3.14159 * radius * radius double getArea(){ return (3.14159 * radius * radius); } }; // Sample run int main() { // Declaring object of Circle Circle myCircle; myCircle.setRadius(5); // printing radius of circle cout<<"Radius of circle is: "<<(myCircle.getRadius())<<endl;...

  • Write a java class definition for a circle object. The object should be capable of setting...

    Write a java class definition for a circle object. The object should be capable of setting radius, and computing its area and circumference. Use this to create two Circle objects with radius 10 and 40.5, respectively. Print their areas and circumference. Here is the Java class file (Circle.java). Compile it. public class Circle{ //Instance Variables private double PI = 3.1459; private double radius; //Methods public Circle ( ) { }    //get method (Accessor Methods ) public double getRadius (...

  • Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All...

    Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All rights reserved. // #include<iostream> #include<fstream> #include<cstdlib> #include<regex> #include <iomanip> using namespace std; float grossPay(float hrsWorked, float payrate); float grossPay(float hrsWorked, float payrate){ return hrsWorked*payrate;       } int main(){    //opening an output file ifstream outFile("Employee.txt", ios::in); //Read variables string depId,emp_num,firstName,lastName,email,hrs_worked,pay_rate,ch="y";    //Regex patterns regex integerPattern("(\\+|-)?[[:digit:]]+"); regex...

  • i am having trouble displaying results and displaying them evenly it is suppose to look like...

    i am having trouble displaying results and displaying them evenly it is suppose to look like this Enter the following data for employee 1: Employee ID: 1298 Hours worked: 35.8 Pay rate (per hour): 23.45 Enter the following data for employee 2: Employee ID: 1899 Hours worked: 34.5 Pay rate (per hour): 19.5 Enter the following data for employee 3: Employee ID: 4435 Hours worked: 30.5 Pay rate (per hour): 20.75 Enter the following data for employee 4: Employee ID:...

  • C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class...

    C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class    double rectWidth; // Local variable for width    double rectLength; // Local variable for length    string rectColor;    // Get the rectangle's width and length from the user.    cout << "This program will calculate the area of a\n";    cout << "rectangle. What is the width? ";    cin >> rectWidth;    cout << "What is the length? ";    cin >>...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT