السلام عليكم ورحمة الله وبركاتة
أخواني الغالين عندي تقريبااا اربعة اسئلة .. ممكن احد يساعدني في حلهاااااا واكون شاكر لكم
---------------------------------------------------
Q1: Write a program that asks user to choose one of these shaps rectangle , right-angled triangle or square then print the selected one out of asterisks (*). knowing that you should read shape's dimension from user. Your output should be something like the following
Example:
Hello, Please choose one of the following shapes
1- Rectangle
input
2- Right-angled triangle
3- Square
Enter your choice: 1
Please enter rectangle width: 8
Please enter rectangle height: 3
* * * * * * * *
* * * * * * * *
* * * * * * * *
----------------------------------
Q2: Write a program for a grocery that reads products data and determine and display the product that has the highest price and the average price. A product has three pieces of data: id (int), name (String) and price (double).Your program should continue reading new products until user enters -1 as id of a product.
Example:
ID Name price
1001 Pepsi 1.5
1021 Kit Kat 2
1011 Chips 1
-1 -1 -1
-----
The most expensive product is:
Id: 1021
Name: Kit Kat
Price: 2 S.R.
Average price = 1.5
Q3: Write a program that reads a set of integers, and then finds and prints the sum of the even and odd integers.
input
Example:
How many numbers in your set of integers? : 6
2 4 3 6 7 1
Sum of odd numbers = 11
Sum of even numbers = 12
(Self study exercise)
Q4: The greatest common divisor (GCD) of two integers is the largest integer that evenly divides each of the two numbers. Write a program that reads two integers and then prints their greatest common divisor.
Example:
Enter first integer: 4
Enter second integer: 8
The greatest common divisor is 4
Hint :
To declare a variable of type string, you need to include the standard string class:
- In the header:
#include <string>
- In the declaration:
string varName