Report

Review the following : Flowcharting • Variable declarations • Output • Input • Arithmetic Calculations • Conditional Statements • Loops • Read in a year and determine if it is a leap year. A leap year is a year that is evenly divisible by 4 and not by 100. Or, a year that is evenly divisible by 400 is also a leap year. Start Prompt Read in year F Leap Year? T Is leap year Is not leap year End //Helen Kow CS 265 Program #1 //This program tells you if a year is #include "stdafx.h" #include <iostream> using std::cin; using std::cout; using std::endl; int main() { int year, rem4, rem100, rem400; cout <<"Enter a year "; cin>> year; rem4 = year%4; rem100 = year %100; rem400 = year % 400; if ( rem4 == 0 && rem100 != 0 || cout << endl << year << " else cout << endl << year << " return 0; } a leap year or not rem400 == 0) is a leap year " << endl; is not a leap year \n“; //Helen Kow CS 265 Program #1 //This program tells you if a year is a leap year or not #include "stdafx.h" #include <iostream> using std::cin; using std::cout; using std::endl; int { main() //code goes here return 0; } int year, rem4, rem100, rem400; year rem4 rem100 rem400 cout <<"Enter a year "; cin>> year; year rem4 rem100 rem400 2018 rem4 = year%4; rem100 = year %100; rem400 = year % 400; year 2018 rem4 2 rem100 18 rem400 18 if ( rem4 == 0 && rem100 != 0 || rem400 == 0) cout << endl << year << " is a leap year " << endl; else cout << endl << year << " is not a leap year \n“; year 2018 rem4 2 rem100 18 rem400 18 Read in a year and determine if it is a leap year. A leap year is a year that is evenly divisible by 4 and not by 100. Or, a year that is evenly divisible by 400 is also a leap year. Allow the user to repeat the program as many times as they desire. ____________ | | | | Code to be | repeated | | | While |_ _ _ _ _ _ _ _ _ condition is true do { //code to be repeated } while (some condition is true ); Start _____________ | | Prompt | | Read | in year | | | Leap | Year? Is not leap | year | | | | Play | again? | | while again == ______ true End Flowchart with loop Is leap year //Helen Kow CS 265 Program #1 //This program tells you if a year is a leap year or not #include "stdafx.h" #include <iostream> using std::cin; using std::cout; using std::endl; int main() { int year, rem4, rem100, rem400; char again; do 2 { cout <<"Enter a year "; cin>> year; rem4 = year%4; rem100 = year %100; rem400 = year % 400; if ( rem4 == 0 && rem100 != 0 || rem400 == 0) cout << endl << year << " is a leap year " << endl; else cout << endl << year << " is not a leap year " << endl; cout << "\nPlay again ?? "; cin >> again; } } while (again == 'y'); return 0; 3 • • • • • • • Flowcharting Variable declarations Output Input Arithmetic Calculations Conditional Statements Loops