Answered step by step
Verified Expert Solution
Link Copied!

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 if/else 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 1: A large enough number to have years and days.
Please enter the number of days to convert to years
890
There are 2 years and 160 days in 890 days.
Screenshot 2: A large enough number for no days remaining, exact year count.
Please enter the number of days to convert to years
1825
There are 5 years in 1825 days.
Screenshot 3: A number that is not large enough to determine years.
Please enter the number of days to convert to years
285
A year is made of 365 days.
You have not entered a large enough value to determine
the number of years.
Screenshot 4: User entering an invalid number.
Please enter the number of days to convert to years
-35
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 =0){
std::cout "Please enter a positive number.
";
}
} while (days =0);
// Calculate years and remaining days
int years = days /365;
int remainingDays = days %365;
// Output the result
std::cout "Number of years: " years;
if (remainingDays >0){
std::cout ", remaining days: " remainingDays;
}
std::cout std::endl;
return 0;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago