Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ooooo AT&T; 4G 2:13 PM catalyst.deanza.edu \'F\': Your Sun Sign is Pisces The Fi

ID: 640681 • Letter: O

Question

ooooo AT&T; 4G 2:13 PM catalyst.deanza.edu 'F': Your Sun Sign is Pisces The Fish They are honest, unselfish, trustworthy and often have quiet dispositions They can be overcautious and sometimes gullible 'R': Your Sun Sign is Aries The Ram Aries people are creative, adaptive, and insightful. Aries are fire signs, and so too is their personality 'B': Your Sun Sign is Taurus The Bull Stubborn by nature, the Taurus w stand his/her ground to the bitter end But that's okay because the Taurus is also a loving, sympathetic and appreciative sign "T": Your Sun Sign is Gemini The Twins Flexibility, balance and adaptability are the keywords for the Gemini. They tend to have a duality to their nature, and can sometimes be tough to predict how they will react 'C': Your Sun Sign is Cancer The Crab Cancerians love home-life, family and domestic settings. They are traditionalists, and enjoy operating on a fundamental level L': Your Sun Sign is Leo The Lion The zodiac signs and meanings of Leo is about expanse, power and exuberance. Leo's are natural born leaders, and have a tendency to be high-minded and vocal about their opinions Prog. HW# 3 page 2 of 3 CIS 22A 'V': Your Sun Sign is Virgo The Virgin Virgo's have keen minds, and are delightful to talk with, often convincing others of outlandish tales with ease and charm. Virgo's are inquisitive and are very skilled at drawing information from people 'S': Your Sun Sign is Libra The Scales As their zodiac signs and meanings would indicate, Libra's are all about balance, justice, equanimity and stability. Libra's are very understanding caring, and often the champion of underdogs. 'N': Your Sun Sign is Scorpio The Scorpion The Scorpio is often misunderstood. These personalities are bold and are capable of executing massive enterprises with cool control and confidence 'A': Your Sun Sign is Sagittarius The Archer They have great ability for focus, and can be very intense. They are not very patient and expect quick results NOTE: BE SURE TO DISPLAY THE INFORMATION SO THE USER CAN READ IT SO IF YOU COPY AND PASTE THE INFO, PUT 'In' TO BREAK INTO LINES (or points off)! See Catalyst for test input and output and for input to use for turnin Include in each program: (follow this completely!) comments and indenting (as specified in Prog. HW#1) (OR POINTS OFF) const declarations as specified above AND USE them in the C++ program (don't just declare idFunction AS DESCRIBED IN HW#3!! do-while loop (AT LEAST ONE) while loop (AT LEAST ONE) switch statements (2 if statements where needed output function DO NOT USE ANY EXTERNAL VARIABLES. external const declarations are OK because they're not variables) Extra Credit Problems (not due until the last lecture day of the quarter!): textbook, 7th Ed. pp. 296 298 #11, #21, #22 (using nested for loops), 8th Ed. pp. 295-297 11 #21, #22 (using nested for loops)

Explanation / Answer

#include <iostream>

using namespace std;

void output(char code){
   switch (code){
   case 'G':
       cout << "Capricorn" << endl;
       break;
   case 'W':
       cout << "Aquarius" << endl;
       break;
   case 'F':
       cout << "Pisces" << endl;
       break;
   case 'R':
       cout << "Aries" << endl;
       break;
   case 'B':
       cout << "Taurus" << endl;
       break;
   case 'T':
       cout << "Gemini" << endl;
       break;
   case 'C':
       cout << "Cancer" << endl;
       break;
   case 'L':
       cout << "Leo" << endl;
       break;
   case 'V':
       cout << "Virgo" << endl;
       break;
   case 'S':
       cout << "Libra" << endl;
       break;
   case 'N':
       cout << "Scorpio" << endl;
       break;
   case 'A':
       cout << "Sagittarius" << endl;
       break;
   case 'X':
       cout << "Invalid Birthdate!" << endl;
       break;
   }
}

int main(){
   int month, day, year;
   // variable month to store month in number form and
   // variable day to store date
   while (true){
       do{
           cout << "Month (Ex: 2): ";
           cin >> month;
       } while ((month < 1 || month > 12) && (cout << "Invalid Month" << endl));
       // asking user for month
       do{
           cout << "Date (Ex: 24): ";
           cin >> day;
       } while ((day < 1 || day > 31) && (cout << "Invalid Day" << endl));
       // asking user for date
       do{
           cout << "Year (Ex: 2005): ";
           cin >> year;
       } while ((year < 1900 || year > 2100) && (cout << "Invalid Year" << endl));

       char code = 'X';
       cout << "Your Astrological sign is: ";
       // if month entered is 3, switch statement jumps the control to case 3
       // more generally if month entered is m, switch statement jumps the control to case m
       // if there is no case m, it jumps to case 'default'
       // if no 'default', it just does nothing
       switch (month){
           // all the following if conditions are self explainotory
       case 1:
           if (day >= 1 && day <= 19){
               code = 'G';
           }
           else if (day >= 20 && day <= 31){
               code = 'W';
           }
           break;
       case 2:
           if (day >= 1 && day <= 18){
               code = 'W';
           }
           else if (day >= 19 && day <= 28){
               code = 'F';
           }
           else if (year % 4 == 0 && day == 29){
               code = 'F';
           }
           break;
       case 3:
           if (day >= 1 && day <= 20){
               code = 'F';
           }
           else if (day >= 21 && day <= 31){
               code = 'R';
           }
           break;
       case 4:
           if (day >= 1 && day <= 19){
               code = 'R';
           }
           else if (day >= 20 && day <= 30){
               code = 'B';
           }
           break;
       case 5:
           if (day >= 1 && day <= 20){
               code = 'B';
           }
           else if (day >= 21 && day <= 31){
               code = 'T';
           }
           break;
       case 6:
           if (day >= 1 && day <= 20){
               code = 'T';
           }
           else if (day >= 21 && day <= 30){
               code = 'C';
           }
           break;
       case 7:
           if (day >= 1 && day <= 22){
               code = 'C';
           }
           else if (day >= 23 && day <= 31){
               code = 'L';
           }
           break;
       case 8:
           if (day >= 1 && day <= 22){
               code = 'L';
           }
           else if (day >= 23 && day <= 31){
               code = 'V';
           }
           break;
       case 9:
           if (day >= 1 && day <= 22){
               code = 'V';
           }
           else if (day >= 23 && day <= 30){
               code = 'S';
           }
           break;
       case 10:
           if (day >= 1 && day <= 22){
               code = 'S';
           }
           else if (day >= 23 && day <= 31){
               code = 'N';
           }
           break;
       case 11:
           if (day >= 1 && day <= 21){
               code = 'N';
           }
           else if (day >= 22 && day <= 30){
               code = 'A';
           }
           break;
       case 12:
           if (day >= 1 && day <= 21){
               code = 'A';
           }
           else if (day >= 22 && day <= 31){
               code = 'G';
           }
           break;
       }
       output(code);
       string ch;
       cout << "Do you want to find another sun sign:(y for yes, n for no) ";
       cin >> ch;
       if (ch == "n" || ch == "N"){
           break;
       }
   }
   return 0;
}