Answer to Question #311121 in C++ for Christine Traya

Question #311121

write a program to input number of days from the user and convert to it years weeks and days and display the result on the screen







// days.cpp





// Author: Mr jake R. pomperada, BSCS, MAED- IT





// Date: august 15, 2018 Wednesday





// Location: Bacolod City, Negros occidental





// Website: http://www.jakerpompereda.com

1
Expert's answer
2022-03-14T08:38:46-0400
// days.cpp
// Author: Mr jake R. pomperada, BSCS, MAED- IT
// Date: august 15, 2018 Wednesday
// Location: Bacolod City, Negros occidental
// Website: http://www.jakerpompereda.com


#include <iostream>
#include <string>
using namespace std;






int main(){
	int days, years, weeks;
	
	cout<<"Enter number of days: ";
	cin>>days;


	/* Conversion */
	years = (days / 365);   // Ignoring leap year
	weeks = (days % 365) / 7;
	days  = days - ((years * 365) + (weeks * 7));


	/* Print all resultant values */
	cout<<"YEARS: "<< years<<"\n";
	cout<<"WEEKS: "<< weeks<<"\n";
	cout<<"DAYS: "<<days<<"\n";


	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment