Write a program that determines the total cost of apples given the number of pou
ID: 3697541 • Letter: W
Question
Write a program that determines the total cost of apples given the number of pounds of apples purchased and the cost per pound of apples. Write a program that prompts the user for the lengths of two sides of a triangle and the angle between them (in degrees) and calculates the length of the third site. Write two functions: a function that reads in hours worked and returns the value entered and a separate function that reads in hourly pay rate and returns value entered. a function that displays in a meaningful way the values of its two arguments that represent gross pay and net pay. Write a program fragment that ignores any negative integer values read as data and finds the sum of only the positive numbers. Write a function compress that removes all blanks from its string argument. If the argument is " this Is One " it should be changed to "thisIsOne".Explanation / Answer
//1.
#include<iostream.h>
void main()
{
double cost, pounds;
cout<<"Enter number of pounds of apple purchased";
cin>>pounds;
cout<<"Enter cost";
cin>>cost;
cout<<"Total cost = "<<(pounds*cost);
}
//2.
#include<iostream.h>
void main()
{
double s1,s2,s3,ang;
cout<<"Enter first side";
cin>>s1;
cout<<"Enter second side";
cin>>s2;
cout<<"Enter angle between 2 sides";
cin>>ang;
s3=s1*s1 + s2*s2;
cout<<"Third side is "<<s3;
}
//3(a).
#include<iostream.h>
int heWork()
{
int he;
cout<<"Enter hours worked";
cin>>hr;
return hr;
}
double hrRate()
{
double ra;
cout<<"Enter hour rate";
cin>>ra;
return ra;
}
void main()
{
int hr;
double rate;
hr=heWork();
rate=hrRate();
}
//3(b).
#include<iostream.h>
void disp(double gr, double net)
{
cout<<"Hello!!! Your Gross Pay is="<<gr<<endl;
cout<<"Your Net Pay is="<<net<<endl;
}
void main()
{
double gr=1455, net=900.5;
disp(gr,net);
}
//4.
#include<iostream.h>
void main()
{
int i=0,sum=0,n;
while(i<5)
{
while(1)
{
cout<<"Enter number";
cin>>n;
if(n>0)
break;
}
sum=sum+n;
i++;
}
cout<<"Sum is "<<sum;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.