Use cloud 9 or X code if you are on Mac to create the following three function s
ID: 3845666 • Letter: U
Question
Use cloud 9 or X code if you are on Mac to create the following three function sets. Submit to GIT when complete. Write a function that Sums all the ASCII values in a C++ string it takes a C++ string as parameter and returns an unsigned value. Please pick a reasonable name and write a short main() function to test it. Pick a 3D Shape and write two functions one to calculate the volume and one to calculate the surface area of that shape. Write the necessary main() to test to these functions. Wind chill in Celsius can be calculated using the following formula: W = 33 - (10 squareroot (v) - v + 10.5)(33 -1)/23.1 Where: v is wind speed in meters/second t is air temperature in degrees Celsius: W is wind chill index (in degrees Celsius) The above equation only valid for an actual air temperatureExplanation / Answer
1.Program:
#include <iostream>
#include <string>
using namespace std;
class Ascii
{
public:
void SumOfAscii()
{
int sum = 0, i, len=0;
char string1[100];
cout<<"Enter the string : ";
cin>>string1;
for(i=0;string1[i]!='';i++)
{
len++;
}
//len = strlen(string1);
for (i = 0; i < len; i++)
{
sum = sum + string1[i];
}
cout<<"Sum Of ASCII Character is "<<sum;
}
};
int main()
{
Ascii obj;
obj.SumOfAscii();
return 0;
}
Output:
Enter the string : Ram
Sum Of ASCII Character is 288
Problem2:
// Example program
#include <iostream>
#include <string>
using namespace std;
class Shape
{
public:
void CalculateVolume(double a)
{
cout<<"Volume of a cube " <<(a*a*a);
}
void SurfaceArea(double a)
{
cout<<" Surface Area of a cube " <<(6*a*a);
}
};
int main()
{
Shape obj;
double a;
cout<<"Enter Edge of a cube ";
cin>>a;
obj.CalculateVolume(a);
obj.SurfaceArea(a);
return 0;
}
Output:
Enter Edge of a cube
5
Volume of a cube 125
Surface Area of a Cube 150
3. Program:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
bool CaluculateWindChill(int &v,int &t);
class WindChill
{
public:
bool CaluculateWindChill(int &v,int &t)
{
bool val=false;
double W;
if(t>=10)
{
W=t;
cout<<" Wind Chill Is "<<W;
}
else
{
W=(33-(10*sqrt(v)-v+10.5)*(33-t))/23.1;
cout<<" Wind Chill Is "<<W;
}
if(W<0)
{
val=true;
}
return val;
}
};
int main()
{
WindChill obj;
int a,b;
cout<<"Enter wind speed ";
cin>>a;
cout<<"Enter temperature ";
cin>>b;
bool val=obj.CaluculateWindChill(a,b);
return 0;
}
Output:
Enter wind speed
5
Enter temperature
11
Wind Chill Is 11
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.