قوة بنات .. شونكم شخباركم
هذي اول مشاركة لي بتجمعكم و ان شاء الله ماتكون الاخيرة وداخلة اطلب مساعدتكم واتمنى انكم ماتخذلوني .. عندي هوم ووركات حليت اغلبيتهم بس بقوا 3 اسئلة ماعرفت احلهم وخاصة انه طريقتهم ليلحين مادرسنا اياها الدكتور بس طلب منا نحلها ونسلمهم الاثنين الجاي وقال دشوا عالنت ودوروا من قوقل بس للاسف مالقيت بقوقل شي يساعدني وابيكم تساعدوني و ان شاء الله ماراح تقصرون معاي و ابي حتى لو تحاولون تحلون سؤال واحد بس مو شرط ثلاثتهم و مشكورين مقدما..
Question 1
Write a program to simulate hand-held electronic calculator. Your program should execute as follows:
• Step 1: display a prompt and wait for the user to enter an instruction code (a single character):
‘+’ for addition
‘-‘ for subtraction
‘*’ for multiplication
‘/’ for division
‘p’ for power
‘c’ to clear the current accumulator
‘s’ for square root
‘l’ for log
‘n’ for ln
‘q’ for quit
• Step 2: (if needed) display a prompt and wait for the user to enter a type float number (which we will call left-operand)
• Step 3: (if needed) display a prompt and wait for the user to enter a type float number (which we will call right-operand)
• Step 4: display the accumulated result at any point during processing and repeat steps 1 through 3 using a GOTO statement (no loops in this assignment).
Use a separate function enter_code to prompt the user for instruction code and to ensure that a valid code is entered. Also, use a separate function enter_operand for the entry of the left-operand and the right-operand. Finally, use another function compute to perform the indicated operation. (unless q was entered).
Question 3A Baby Sitting Problem: A baby sitter charges $1.50 per hour until 9:00 pm (while the kids are still up), $1.00 per hour between 9:00 pm and midnight, and $1.25 per hour after midnight (since late night baby sitting interferes with morning classes).
Write a program that reads the sitter's starting time in hours and minutes and the ending time in hours and minutes and then computes the sitter's fee. Assume all times are between 6:00 pm and 6:00 am; hours should be entered as numbers on a 12-hour clock, so that hour 3 should be considered as 3:00 am and hour 8 should be considered as 8:00 pm. Hours outside the range 1 to 12 should be considered invalid.
[Note: You may not use a 24 hour clock for this problem. Also, times must be given in hours and minutes (as two nonnegative integer values).]
Question 4Write a program to get a date from the user in the format day/month/year. Tip: use extra variables to read the /. The program should check the three parts of the date (day, month, year), and print a warning message for any part of the date that is wrong. If the whole date is correct, it should print a message saying that the date is valid. The normal rules for dates apply: valid days are from 1 to 28, 29, 30, or 31 (depending on the month and on whether the year is a leap year. You might want to use a switch statement to perform this task.); valid months are from 1 to 12; valid years start from 1582 (the year in which our current calendar system started). The rule for deciding if a year is a leap year is as follows: a year evenly divisible by 4 is a leap year; except if the year is evenly divisible by 100, in which case it is not a leap year; except if the year is evenly divisible by 400, in which case it is a leap year.
Examples:
./date_check
Enter a date (d/m/y): 29/2/2002
The day 29 is not valid!
./date_check
Enter a date (d/m/y): 32/15/1002
The year 1002 is not valid!
The month 15 is not valid!
The day 32 is not valid!
./date_check
Enter a date (d/m/y): 20/9/2002
The given date is valid.