Commit a796605f authored by Brandon Reid's avatar Brandon Reid

autosave

parent bc00cf2b
#include "Functions.h"
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
// Input checking functions
int yearPrompt (int year) {
do {
cout << "Enter year: ";
if (!(cin >> year)) { // validates that numbers were entered and checks input
cerr << "Error! Please enter a valid integar." << endl;
cin.clear();
cin.ignore(1000, '\n');
continue;
}
if (isLeap(year)) { // Tells user if it is a leap year of not
cout << "This is a leap year." << endl;
} else if (!isLeap(year)) {
cout << "This is not a leap yar." << endl;
}
if (year > 0 && year < 9099) {
return year;
} else {
cerr << "Error! Invalid year. Please enter a year between 1 and 9099" << endl;
}
} while (true);
}
string monthPrompt (string month) {
do {
cout << "Enter month: ";
cin >> month;
if (month == "January" || month == "February" || month == "March" || month == "April" || month == "May" || month == "June" || month == "July" || month == "August" || month == "September" || month == "October" || month == "November" || month == "December") {
return month;
} else {
cerr << "Error! Please enter a valid month." << endl;
}
} while (true);
}
int dayPrompt (string month, int day, int year) {
do {
cout << "Enter day: ";
if (!(cin >> day)) { // validates that numbers were entered and checks input
cerr << "Error! Please enter a valid integar." << endl;
cin.clear();
cin.ignore(1000, '\n');
continue;
}
if (month == "January" || month == "March" || month == "May" || month == "July" || month == "August" || month == "October" || month == "December") {
if (day > 0 && day <= 31) {
return day;
}
}
if (month == "April" || month == "June" || month == "September" || month == "November") {
if (day > 0 && day <= 30) {
return day;
}
}
if (month == "February") {
if (isLeap(year)) {
if (day > 0 && day <= 29) {
return day;
}
} else if (!isLeap(year)) {
if (day > 0 && day <= 28) {
return day;
}
}
}
cerr << "Error! Please enter a valid date." << endl;
} while (true);
}
int hourPrompt (int hour) {
do {
cout << "Enter hour (0 - 23): ";
if (!(cin >> hour)) { // validates that numbers were entered and checks input
cerr << "Error! Please enter a valid integar." << endl;
cin.clear();
cin.ignore(1000, '\n');
continue;
}
if (hour >= 0 && hour < 24) {
return hour;
} else {
cerr << "Error! Please enter a valid hour." << endl;
}
} while (true);
}
int minutePrompt (int minute) {
do {
cout << "Enter minute: ";
if (!(cin >> minute)) { // validates that numbers were entered and checks input
cerr << "Error! Please enter a valid integar." << endl;
cin.clear();
cin.ignore(1000, '\n');
continue;
}
if (minute >= 0 && minute < 60) {
return minute;
} else {
cerr << "Error! Please enter a valid minute." << endl;
}
} while (true);
}
string directionPrompt (string direction) { // prompts user for input and asked for direction (East, West, North, South, Northeast, Northwest, Southeast, Southwest)
}
double anglePrompt (double angle) { //prompts user for the angle they are looking at (0.0 - 90.0 degrees)
}
double dateToHour (string month, int day, int hour, int minute) { // Converts the date into hours
//variables
double totHours = 0;
int monthNum = 0;
if(month == "January") {
monthNum = 1;
} else if (month == "February") {
monthNum = 2;
} else if (month == "March") {
monthNum = 3;
} else if (month == "April") {
monthNum = 4;
} else if (month == "May") {
monthNum = 5;
} else if (month == "June") {
monthNum = 6;
} else if (month == "July") {
monthNum = 7;
} else if (month == "August") {
monthNum = 8;
} else if (month == "September") {
monthNum = 9;
} else if (month == "October") {
monthNum = 10;
} else if (month == "November") {
monthNum = 11;
} else {
monthNum = 12;
}
totHours += (monthNum * 730) + (day * 24) + (minute / 60);
return totHours;
}
bool isLeap (int year) { // bool check for leap year
if ((year % 4) == 0) {
return true;
} else {
return false;
}
}
\ No newline at end of file
#include <string>
using namespace std;
int yearPrompt (int year);
string monthPrompt (string month);
int dayPrompt (string month, int day, int year);
int hourPrompt (int hour);
int minutePrompt (int minute);
double dateToHour (string month, int day, int hour, int minute);
bool isLeap (int year);
\ No newline at end of file
#include <iostream>
#include "Functions.h"
#include <vector>
#include <string>
using namespace std;
int main () {
//variables
string monthInput;
string input3;
int monthDay = 0;
int yearInput = 0;
int hourInput = 0;
int minuteInput = 0;
int input1 = 0;
int input2 = 0;
int input4 = 0;
int input5 = 0;
cout << "==============Welcome to the Star-Gazer v 1.0==============" << endl;
do {
yearInput = yearPrompt(input1);
monthInput = monthPrompt(input3);
monthDay = dayPrompt(monthInput, input2, yearInput);
hourInput = hourPrompt(input4);
minuteInput = minutePrompt(input5);
} while (false);
//cout << dateToHour(yearInput, monthInput, monthDay, hourInput, minuteInput) << endl;
return 0;
}
\ No newline at end of file
project-3-star-gazing @ e5a00be2
Subproject commit e5a00be2e6742d72c948eb39ed19c039efa7c4fa
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment