[SOLVED] CS115 Lab Guide 01A-Data, expressions, conditional statements

35.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

 

1. Write a program that inputs a value for x and outputs the value of y according to the given function:

y = x3 + 3x+ 9

x2

Sample Run:

Input x: 2
The result of the expression: 5.75

2. Write a program that inputs an integer value from the user. Your program should give an appropriate message for positive even values, positive odd values, zero and negative values.

Sample Run 1:
Enter an integer number: -5
Number is not positive

Enter an integer number: 4
Value even and positive

Enter an integer number: 3
Value odd and positive

Enter an integer number: 0
Number is zero

3. Write a program to prepare a menu for a restaurant customer. The customer will input their budget, and the program will compute their bill based on the following. The customer must order a main dish (15TL). If they have money remaining, a starter, dessert or both will be added to their menu, depending on the remaining budget. The price of the starter is 10TL and the dessert is 8 TL.

The program will display the final bill, as well as their remaining budget.
Sample Run:
Enter budget: 24 Main dish added.
Budget not sufficient for starter…
Dessert added.
Total Meal Cost: 23 Remaining Budget: 1
Sample Run:
Enter budget: 50 Main dish added.
Starter added.
Dessert added.
Total Meal Cost: 33 Remaining Budget: 17 Sample Run:
Enter budget: 12
More money needed

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.