0% found this document useful (0 votes)
21 views4 pages

C++ Assignment 2

The document contains code for a C++ program that takes a user's birth month and day as input and outputs their astrological sign and horoscope based on date ranges assigned to each sign. It uses if/else statements to check the month and day against the ranges for each sign and display the corresponding output. The program then asks if the user wants to try again and repeats in a loop if they enter Y or y.

Uploaded by

abduwasi ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

C++ Assignment 2

The document contains code for a C++ program that takes a user's birth month and day as input and outputs their astrological sign and horoscope based on date ranges assigned to each sign. It uses if/else statements to check the month and day against the ranges for each sign and display the corresponding output. The program then asks if the user wants to try again and repeats in a loop if they enter Y or y.

Uploaded by

abduwasi ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MIZAN-TEPI UNIVERSITY

#include <iostream>

using namespace std;

int main() {

int day, month;

char choice;

do {

cout << "Enter your birth month (1-12): ";

cin >> month;

cout << "Enter your birth day (1-30): ";

cin >> day;

if ((month == 3 && day >= 21) || (month == 4 && day <= 19)) {

cout << "Your sign is Aries." << endl;

cout << "Horoscope: You are a natural leader and have a strong sense of
adventure. Use your energy to pursue your goals." << endl;

} else if ((month == 4 && day >= 20) || (month == 5 && day <= 20)) {

cout << "Your sign is Taurus." << endl;

cout << "Horoscope: You are reliable and practical. Take time to enjoy the
simple pleasures in life." << endl;

} else if ((month == 5 && day >= 21) || (month == 6 && day <= 21)) {
cout << "Your sign is Gemini." << endl;

cout << "Horoscope: You are curious and adaptable. Embrace change and
keep an open mind." << endl;

} else if ((month == 6 && day >= 22) || (month == 7 && day <= 22)) {

cout << "Your sign is Cancer." << endl;

cout << "Horoscope: You are sensitive and nurturing. Take care of yourself
and those around you." << endl;

} else if ((month == 7 && day >= 23) || (month == 8 && day <= 22)) {

cout << "Your sign is Leo." << endl;

cout << "Horoscope: You are confident and charismatic. Use your talents to
make a positive impact on the world." << endl;

} else if ((month == 8 && day >= 23) || (month == 9 && day <= 22)) {

cout << "Your sign is Virgo." << endl;

cout << "Horoscope: You are analytical and organized. Focus on self-
improvement and personal growth." << endl;

} else if ((month == 9 && day >= 23) || (month == 10 && day <= 22)) {

cout << "Your sign is Libra." << endl;

cout << "Horoscope: You are balanced and diplomatic. Seek harmony in
your relationships and surroundings." << endl;

} else if ((month == 10 && day >= 23) || (month == 11 && day <= 21)) {

cout << "Your sign is Scorpio." << endl;

cout << "Horoscope: You are intense and passionate. Use your intuition to
navigate complex situations." << endl;

} else if ((month == 11 && day >= 22) || (month == 12 && day <= 21)) {

cout << "Your sign is Sagittarius." << endl;


cout << "Horoscope: You are adventurous and optimistic. Follow your
dreams and take risks." << endl;

} else if ((month == 12 && day >= 22) || (month == 1 && day <= 19)) {

cout << "Your sign is Capricorn." << endl;

cout << "Horoscope: You are ambitious and disciplined. Focus on


achieving your goals with hard work and perseverance." << endl;

} else if ((month == 1 && day >= 20) || (month == 2 && day <= 18)) {

cout << "Your sign is Aquarius." << endl;

cout << "Horoscope: You are independent and unconventional. Embrace


your unique qualities and use them to make a difference." << endl;

} else if ((month == 2 && day >= 19) || (month == 3 && day <= 20)) {

cout << "Your sign is Pisces." << endl;

cout << "Horoscope: You are empathetic and creative. Use your
imagination to bring beauty and joy into the world." << endl;

} else {

cout << "Invalid input. Please try again." << endl;

cout << "Do you want to try again? (Y/N): ";

cin >> choice;

} while (choice == 'Y' || choice == 'y');

return 0;

}
QUESTION 1
#include <iostream>

using namespace std;

int main() {

float height, weight;

cout << "Enter your height in centimeters: ";

cin >> height;

cout << "Enter your weight in kilograms: ";

cin >> weight;

if (weight < height/2.5) {

cout << "You are underweight.";

} else if (height/2.5 <= weight && weight <= height/2.3) {

cout << "You have a normal weight.";

} else {

cout << "You are overweight.";

return 0;

You might also like