4.4: The if/else Statement

¡Supera tus tareas y exámenes ahora con Quizwiz!

Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the variable nonSeniors otherwise.

if (age >=65) seniorCitizens++; else nonSeniors++;

Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison assigns salesTrend the value -1 or 1. -1 represents the case where soldYesterday is greater than soldToday; 1 represents the case where soldYesterday is not greater than soldToday.

if (soldYesterday>soldToday) salesTrend=-1; else salesTrend=1;

Write an if/else statement that assigns true to the variable fever if the variable temperature is greater than 98.6; otherwise it assigns false to fever.

if (temperature>98.6) fever=true; else fever=false;


Conjuntos de estudio relacionados

Michigan State University Psychology 101 Exam 4

View Set

Fundamentals of Success Gastrointestinal System

View Set

Maternity- Labor and Delivery and Associated Complications

View Set

Chapter 46: Management of Patients With Gastric and Duodenal Disorders Prep-U

View Set

Counseling and Helping Relationships

View Set

Auto Insurance, Commercial General Liability Insurance, Workers Compensation Insurance

View Set

MCAT - Biochem - Glycolysis, Gluconeogenesis, and Pentose Phosphate Pathway

View Set

2.6 - Cell Division, Cell Diversity & Cell Differentiation

View Set