$24
Lab Objectives: Decisions (if/else)
• For all labs in CS 101, your solutions must conform to these CS101 style guidelines(rules!)
• Create a Lab03 workspace (i.e. the folder H:\private\cs101\lab03). This assignment has parts a, b, and c, each of which should be placed in a separate project within the same Lab03 workspace. Note: only one project is active at a time. To work (Build/Run) a different project, right click on the project's name and select "Set as active project".
• You can only use if/else if/else statements for this lab assignment. You cannot use any repetition statements.
a. Create a new project Lab03a. Write a Java program that takes a real number, x, and calculates the result of the following function:
Note: Math.sqrt( num ) calculates the square root of num, Math.exp( num ) returns enumand Math.pow( num, power ) calculates num raised to power.
Sample runs:
1
b. Create a new project Lab03b. Your program will input three numbers and print “increasing” if they are in increasing order, “decreasing” if they are in decreasing order, and “neither” otherwise. Here, “increasing” means “strictly increasing”, with each value larger than its predecessor. The sequence 3 4 4 would not be considered increasing.
Sample runs:
c. Create a new project Lab03c. Your program prompts the user to enter four integers and prints “two pairs” if the input consists of two matching pairs (in some order) and “not two pairs” otherwise.
Sample runs:
2