Answered step by step
Verified Expert Solution
Question
1 Approved Answer
help to finish my c + + code please Write a program that has the user enter an integer value representing some number of days
help to finish my c code please Write a program that has the user enter an integer value representing some number of days a large number You need to
verify that the number entered is a positive number, if not the user should be given the opportunity to enter another value.
Properly using the modulus operator and ifelse statements print out the number of years that the number entered
represents, if there are days left over, those should also be provided.
Note: If there are no days left over, then the days should NOT be printed.
There are four screenshots for this problem:
Screenshot : A large enough number to have years and days.
Please enter the number of days to convert to years
There are years and days in days.
Screenshot : A large enough number for no days remaining, exact year count.
Please enter the number of days to convert to years
There are years in days.
Screenshot : A number that is not large enough to determine years.
Please enter the number of days to convert to years
A year is made of days.
You have not entered a large enough value to determine
the number of years.
Screenshot : User entering an invalid number.
Please enter the number of days to convert to years
You have entered an invalid number.
Please run the program again.#include
int main
int days;
Prompt the user for input until a positive integer is entered
do
std::cout "Enter the number of days a large number: ;
std::cin days;
if days
std::cout "Please enter a positive number.
;
while days ;
Calculate years and remaining days
int years days ;
int remainingDays days ;
Output the result
std::cout "Number of years: years;
if remainingDays
std::cout remaining days: remainingDays;
std::cout std::endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started