CO_101 Assignment 2 - 2024 PDF

Document Details

Uploaded by Deleted User

2024

Tags

C++ programming assignment computer programming coding problems programming exercises

Summary

This document contains a C++ programming assignment with various problems addressing topics like if-else statements, switch statements, and calculations for temperatures, numbers, votes, grade-evaluation, and triangle classification. The deadline is 8/Nov/2024. These are presented for practice. 2024 programming assignment instructions.

Full Transcript

Assignment 2 **Date:** 3 / Nov / 2024 **Deadline**: 8 / Nov /2024 -- \[11:59 PM\] - Answers will be published on \[ 9 / Nov / 2024 \] for you to study as practice. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ **Instructions for Solving Your First C++ Problem Sheet:** 1. **...

Assignment 2 **Date:** 3 / Nov / 2024 **Deadline**: 8 / Nov /2024 -- \[11:59 PM\] - Answers will be published on \[ 9 / Nov / 2024 \] for you to study as practice. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ **Instructions for Solving Your First C++ Problem Sheet:** 1. **Read Carefully**: Start by reading each question thoroughly. Make sure you understand what is being asked before you start coding. 2. **Plan Before Coding**: Outline your approach in simple steps or pseudocode. This will help you organize your thoughts and identify the key steps. 3. **Write Small Parts First**: Don\'t try to solve the entire problem at once. Start by writing code for smaller sections, test them, and gradually build up to the full solution. 4. **Test Frequently**: Test your code often with different inputs to ensure it's correct. This helps you catch and fix issues early on. 5. **Research and Review**: If you\'re unsure about syntax or concepts, take a moment to review your class notes or look up examples. Practicing this will build your understanding and confidence. 6. **Don't Rush**: Since there are no answers provided, solving each problem fully on your own is essential for learning. Take your time and aim to understand each step. You will upload this assignment with a word document and c++ file 7. **Avoid Internet Shortcuts**: Avoid searching online for complete answers or solutions. While it might seem quicker, it will prevent you from learning the concepts fully. Focus on problem-solving and rely on your knowledge and notes. **Delivering the sheet:** You will be uploading a **compressed folder** on LMS section (**Assignment \_2 uploading)** that contains: - In Section (A) are solved in ***.cpp files( c++ file)*** - Each will be named as the following: - With the name of (Q1\_(your\_first\_name)) - Example: - And for Q2: and so on.... - Rest of the questions **(Section -B )** , will be answered in a Word file format ,with each having the problem number in the beginning of your answer. - **Be careful**, as each student will have only one Allowed attempt, So check your folder content and your answers twice before uploading. ***Before uploading your solution***, **YOU MUST compress your project folder into a.zip file**. This keeps all your files organized and ensures everything is uploaded correctly. Name the file with your **full name and student ID** for easy identification. - Your folder should look like this: ![](media/image4.png) A. Open C++ IDE and answer the following questions: Problem1: **Basic Temperature Check**: Write a program that takes a temperature input from the user and prints \"Hot\" if it is above 30°C and \"Cold\" if it is 30°C or below. Problem 2 : **Odd or Even Checker**: Ask the user to enter a number. Use an if-else statement to print \"Even\" if the number is divisible by 2, otherwise print \"Odd.\" Problem 3 : **Pass or Fail**: Write a program that takes a student's score as input. If the score is 50 or above, print \"Pass,\" otherwise print \"Fail.\" Problem 4 : **Positive, Negative, or Zero**: Ask the user to enter a number. Print \"Positive\" if it\'s above 0, \"Negative\" if it\'s below 0, and \"Zero\" if it\'s exactly 0. Problem 5 : **Voting Eligibility Checker**: Write a program that asks the user for their age and prints \"Eligible to vote\" if they are 18 or older, otherwise prints \"Not eligible to vote.\" Problem 6 : **Grade Evaluator**: Write a program that takes a score from 0 to 100 and uses if-else statements to print the grade as follows: - 90 and above: \"A\" - 80-89: \"B\" - 70-79: \"C\" - 60-69: \"D\" - Below 60: \"F\" Problem 7: **Triangle Type Checker**: Take three side lengths of a triangle as input. Use if-else statements to determine if the triangle is equilateral (all sides equal), isosceles (two sides equal), or scalene (all sides different). Problem 8 : **Largest of Two Numbers**: Write a program that takes two numbers as input and prints the larger one. If they are equal, print \"Both numbers are equal.\" Problem 9 : **Login Authentication:** Ask the user to enter a username and password. Check if they match predefined values (\"admin\" and \"1234\"). If both match, print \"Login Successful.\" If only the username matches, print \"Incorrect Password.\" If neither match, print \"Invalid Username and Password.\" Problem 10 : - Divisible by all three numbers: \"Divisible by 2, 3, and 5\" - Divisible by 2 and 3 only: \"Divisible by 2 and 3\" - Divisible by 3 and 5 only: \"Divisible by 3 and 5\" - Divisible by 2 and 5 only: \"Divisible by 2 and 5\" - Divisible by any one: \"Divisible by \\" - Not divisible by any: \"Not divisible by 2, 3, or 5\" Problem 11 : Problem 12 : Problem 13 : - A: \"Excellent!\" - B: \"Good job!\" - C: \"Fair performance.\" - D: \"Needs improvement.\" - F: \"Fail.\" If the user enters a grade outside these options, print \"Invalid grade.\" B. Read the code carefully and determine the output. Problem 14 : A computer screen shot of a code Description automatically generated Problem 15 : ![A screenshot of a computer program Description automatically generated](media/image6.png) \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ - **Eng. Rana Hamed.** - **Eng. Nouran El-Masry.**

Use Quizgecko on...
Browser
Browser