[Solved] CS135-Project 2

$25

File Name: CS135-Project_2.zip
File Size: 141.3 KB

SKU: [Solved] CS135-Project 2 Category: Tag:
5/5 - (1 vote)

Project [2]: Logical Expressions and Branching Statements

Project Goals

The goals of this project are to:

  1. Get students familiar with evaluating logical expressions
  2. Get students familiar with if else statements
  3. Get students familiar with if else if else statements

Important Notes:

  1. Formatting: Make sure that you follow the precise recommendations for the output content and formatting: for example, do not change the text of the problem from Enter volumes and price per volume for collection 1: to Enter volume, price: . Your assignment will be auto-graded and any change in formatting will result in a loss in the grade.
  2. Comments: Header comments are required on all files and recommended for the rest of the program. Points will be deducted if no header comments are included.

Problem 1

Write a program that asks the user to enter information about three book collections. Each collection has a number of volumes and a price per volume (same for each volume in the collection). The program should ask how many volumes and what is the price per volume for each collection, as well as a budget available for a buyer named Bob. All values entered should be integers. The program should evaluate a set of logical expressions and print out specific messages based on the truth value of those expressions. The expressions are as follows:

  • Bob has money.

If the condition is true (budget is greater than 0) the program should print:

(1) Bob has some money to buy collections.

If the condition is false, the program should print:

(1) Bob does not have money to buy anything.

  • At least two collections are more expensive than Bobs Budget.

If the condition is true the program should print:

  • At least two collections are more expensive than Bobs budget.

If the condition is false, the program should print:

(3) At least two collections are cheaper than or equal to Bobs budget.

  • All the collections cost the same, only two collections cost the same, or no collections cost the same.

If all the collections cost the same, the program should print:

  • All the collections cost the same.

If only two collections cost the same, the program should print:

(4) Only two collections cost the same amount of money.

If none of the collections cost the same, the program should print:

(4) No collections have the same price.

  • Only one collection is cheaper than or equal to Bobs budget.

If the condition is true, the program should print:

  • Only one collection is cheaper than or equal to Bobs budget.

If the condition is false, the program should print:

(4) More than one collection is cheaper than or equal to Bobs budget or they are all more expensive.

  • The maximum number of collections that Bob can buy.

If Bob can buy all the collections, the program should print:

  • Bob can buy all three collections.

If Bob can only buy two of the collections, the program should print:

(5) Bob can only buy two of the collections.

If Bob can only buy one of the collections, the program should print:

(5) Bob can only buy one collection.

If Bob cant buy any collection, the program should print:

(5) Bob cannot buy any collection.

The program should function as follows (items underlined are to be entered by the user):

Enter volumes and price per volume for collection 1: 2 20

Enter volumes and price per volume for collection 2: 3 30

Enter volumes and price per volume for collection 3: 4 50

Enter Bobs budget: 100

  • Bob has some money to buy collections
  • At least two collections are cheaper than or equal to Bobs budget.
  • No collections have the same price.
  • More than one collection is cheaper than or equal to Bobs budget or they are all more expensive (5) Bob can only buy one collection.

Save your program as collections.c

Challenge for problem 1 (10 extra credit points):

Your program should also check the following conditions (you can add them at the end of the previous 5 in the original program):

(6) Bob has enough money to buy any one of the three collections.

If the condition is true the program should print:

  • Bob has enough money to buy any one of the three collections.

If the condition is false, the program should print:

  • Bob does not have enough money to buy any one of the three collections.
  • Bob does not have enough money to buy any collection.

If the condition is true, the program should print:

  • Bob does not have enough money to buy any collection.

If the condition is false, the program should print:

(7) Bob can buy at least one collection.

The program should function as follows (items underlined are to be entered by the user):

Enter volumes and price per volume for collection 1: 2 20

Enter volumes and price per volume for collection 2: 3 30

Enter volumes and price per volume for collection 3: 4 50

Enter Bobs budget: 100

  • Bob has some money to buy collections
  • At least two collections are cheaper than or equal to Bobs budget.
  • No collections have the same price.
  • More than one collection is cheaper than or equal to Bobs budget or they are all more expensive
  • Bob can only buy one collection.
  • Bob does not have enough money to buy any one of the three collections. (7) Bob can buy at least one collection.

Save your challenge separately as collections_c.c

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS135-Project 2
$25