Starting from:

$34.99

CS115 Lab 1-Data, expressions, conditional statements Solution

Lab Guide 01A

Lab Objectives: Data, expressions, conditional statements


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

More products