Write a C++ program that accepts a character using the cin object and determines
ID: 3625040 • Letter: W
Question
Write a C++ program that accepts a character using the cin object and determines whether the character is a lowercase letter. A lowercase letter is any character that is greater than or equal to 'a' and less than or equal to 'z'. If the entered character is a lowercase letter, display the mssage The character just entered is a lowercase letter. If the entered letter is not lowercase, display the message The character just entered is not a lowercase letter.Write a C++ program to compute and display a person's weekly salary as determined by the following expressions:
If the number of hours worked is less than or equal to 40, the person receives $8.00 per hour; otherwise, the person receives $320.00, plus $12.00 for each hour worked over 40 hours.
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
int regularPay = 8;
int overTimePay = 12;
int hoursWorked;
int totalPay = 0;
cout<<"please enter hours worked: ";
cin>>hoursWorked;
if (hoursWorked > 40)
{
totalPay = (hoursWorked - 40) * overTimePay; //This figures out how much made in overtime
totalPay = totalPay + (40 * regularPay);
cout<< "Total Pay is " << totalPay<<endl;
}
else if(hoursWorked > 0 && hoursWorked < 40)
{
totalPay = hoursWorked * regularPay;
cout<< "Total Pay is " << totalPay<<endl;
}
else
{
cout<<"The idiot worked negative hours! HE OWES US MONEY!"<<endl;
}
system("pause");
return 0;
}
//this is for question 2
#include<iostream>
using namespace std;
int main()
{
char ch;
cout << "Enter Character :?";
cin >> ch;
if( ch >= 'a' && ch <= 'z')
cout<< "The character just entered is a lowercase letter."<<endl;
else
cout<<"The character just entered is not a lowercase letter"<<endl;
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.