CSC1300: LAB 4

$30.00 $24.00

Concepts caffeine levels – lab4a.cpp A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans. Ask the user for the caffeine amount (in mg) as input. Validate that they entered a positive value greater…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

Concepts

caffeine levels – lab4a.cpp

A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans.

Ask the user for the caffeine amount (in mg) as input.

Validate that they entered a positive value greater than zero. If they did not, then tell the user that their input was invalid and allow them to enter in the value again.

Output the caffeine level after 6, 12, and 18 hours with two digits after the decimal point.

example

If the input is:

100

the output is:

After 6 hours: 50.00 mg

After 12 hours: 25.00 mg

After 18 hours: 12.50 mg

Note: A cup of coffee has about 100 mg. A soda has about 40 mg. An “energy” drink (a misnomer) has between 100 mg and 200 mg.

Save your program as Lab4a.cpp.

seasons – lab4B.cpp

Write a program that takes a date as input and outputs the date’s season.

The input is a string to represent the month and an int to represent the day.

Check if the input (both the string & int) are valid (an actual month and day).

The dates for each season are:

  • spring: March 20 – June 20
  • summer: June 21 – September 21
  • autumn: September 22 – December 20
  • winter: December 21 – March 19

Example 1

If the input is:

April 11

the output is:

spring

example 2

If the input is:

Blue 65

the output is:

invalid

What to Turn In

Zip Lab4a.cpp and Lab4b.cpp together in a zip folder and then upload to Lab 4.

CSC1300: LAB 4
$30.00 $24.00