Sale!

WIX1002 Lab 3 Flow of Control (Selection) solution

$30.00 $25.50

Category:

Description

5/5 - (4 votes)

Fundamentals of Programming

1. Write a program that stimulates a simple calculator. It reads two integers and a
character. If the character is a +, the sum is printed; if it is a -, the difference is
printed; if is a *, the multiplication is printed; if it is a /, the quotient is printed; and if
it is a %, the remainder is printed. (Use the String.charAt(0) to return the character)
2. Generate a random integer within 0 to 5 and display the integer in word.
2 is two.
3. Write a program that calculates the total commission receives based on the table
below. The program will accept the sales volume and calculate the commission.
Display the commission in two decimal places.

Sales Volume Commission

Less than or equal to 100 5% of total sales
Greater than 100 and less than or equal to 500 7.5% of total sales
Greater than 500 and less than or equal to 1000 10% of total sales
Greater than 1000 12.5% of total sales
4. Write a simple two players dice game. Each player will roll the dice twice and the
player with the highest score wins the game.
5. Cramer’s rule is used to solve the linear equations.
ax + by = e, cx + dy = f; x = (ed-bf)/(ad-bc) y=(af-ec)/(ad-bc)
Write a program that ask the user to enter a, b, c, d, e, f. and display the result of x
and y. If ad – bc is equal to 0. Display “The equation has no solution”
6. Write a program that asks users to enter the radius of a circle and a coordinate point
(x, y). Determine whether the point is inside or outside the circle centered at (0, 0).