Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Help Complete the implementation of the following programs Q1. // This progr

ID: 3562400 • Letter: C

Question

C++ Help

Complete the implementation of the following programs
Q1.
// This program extracts the rightmost digit of a number
#include <iostream>
using namespace std;
int main()
{
int number = 12345;
int rightMost = ____________________________;
cout << "The rightmost digit is" << rightMost << endl;
return 0;
}


Q2.


// This program uses if-else statement to output if a number is even or odd
#include <iostream>
using namespace std;
int main()
{
int number;
cout << "Enter number" << endl;
cin >> number
// Complete the remaining program
return 0;
}

Q3.


// This program outputs if an applicant qualifies for a loan.
// An applicant qualifies if she either has a minimum income of $50,000
// or has worked for more than 2 years
#include <iostream>
using namespace std;
int main()
{
double income;
int years;
cout << "Enter your income" << endl;
cin >> income;
cout << "Enter the number of years worked" << endl;
cin >> years;
1

Explanation / Answer

Q1.
// This program extracts the rightmost digit of a number

SOLUTION: If you want to get the right most digit of a number as output then you just have to divide the number by 10.

example : 12345%10 = 5.
#include <iostream>
using namespace std;
int main()
{
int number = 12345;
int rightMost = number%10;
cout << "The rightmost digit is" << rightMost << endl;
return 0;
}


Q2.


// This program uses if-else statement to output if a number is even or odd

SOLUTION: If you want to test whether the given number is even or odd, you just have to divide it by 2. if remainder is equal to 0(zero), even number else odd number.
#include <iostream>
using namespace std;
int main()
{
int number;
cout << "Enter number" << endl;
cin >> number
if(number%2 = = 0)

{

cout<<" the entered number is even";

}

else

{

cout<<" the entered number is odd."

}
return 0;
}

Q3.


// This program outputs if an applicant qualifies for a loan.
// An applicant qualifies if she either has a minimum income of $50,000
// or has worked for more than 2 years

SOLUTION: To test whether the applicant is qualified for loan, you just have to use logical and operator(||).
#include <iostream>
using namespace std;
int main()
{
double income;
int years;
cout << "Enter your income" << endl;
cin >> income;
cout << "Enter the number of years worked" << endl;
cin >> years;

if(income >= 50000 || years > 2)

{

   cout << "The applicant is eligible to apply for the loan" << endl;?

}

else

{

   cout << "The applicant is not eligible to apply for the loan" << endl;

}

}

Above shown logics that are given in bold work exactly. Hence, problem solved.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote