3 question about java

profilebymustea
csc110.docx

CSC110 – Programming Assignment 1 (Java program)

Write a JAVA program that will compute the values of the 3 expressions given below. Your program should declare the variables a, b, and c as integer, and the values p, q, and r as floating point (use the double type qualifier). Run the program 3 times using the following sets of input values.

Expression 1: (Use 3.1416 as the value of

Expression 2: (Determine both values of “x”)

NOTE: For expression 2

1, Declare a, b, and c as double.

2. To calculate the square root of a number x, use the method Math.sqrt(x)

Expression 3:

Run #1: a = 1, b = 4, c = 2 r = 7.0

Run #2: a = 3, b = 5, c = 1 r = 9.0

Run #3: a = 2, b =10, c = 3 r = 2.0

CSC110 – Programming Assignment 2 (JAVA program)

 

A movie theater charges its customers for each film in accordance with the following rules:

If the age entered is 12 or under, the program should display “Charge = $10.00”

If the age entered is 13 or older, the program should display “Charge = $25.00”

Seniors (age 65 or older) are given a 25% discount.

However, if the time is earlier than 5, the charge should be $10.00 regardless of age.

One exception: If the movie is part of a film festival, the charge will be $15.00 per seat regardless of age or time (hint: use a Boolean variable for this).

Write a JAVA program that will allow the user to enter the values for integer variables age and time. An additional Boolean variable will be required to indicate if the movie in question is part of a film festival. The program should contain logic that will process the input and print (display) the correct output (i.e., the amount to be charged):

Test your program with the following input combinations:

 

age     time          film festival?

10           4              no

13           4              no

11           7              yes

67           3              yes        

64           8              no

68           8              no

25           9              yes

32           3              no

CSC110 – Programming Assignment 3 (JAVA program: Looping)

 

Write and run a JAVA program using a repetition structure (while or for) that will add a series of numbers (integers) with the following parameters:

Starting number is the variable FIRST (inclusive)

Ending number is the variable LAST (inclusive)

Interval between numbers is the variable DELTA (integer)

Sum of the integers is SUM (integer)

Assume all integers are positive and LAST > FIRST

 

Test your program with the following data:

                FIRST     LAST      DELTA

1         100         1

0         100         2

0           10         5

CSC110 – Programming Assignment 4 (JAVA Program using methods)

 

Write and run a JAVA program to calculate and print the areas of 3 geometric shapes (Rectangle, triangle, and circle) using methods as follows:

1.  Write 3 separate methods to calculate the areas of the 3 shapes, one method per shape. Input parameters will be

a. L and W for the rectangle length and width, respectively

b. B and H for the triangle base and height respectively

c. R for the circle radius (use 3.1416 for pi)

2. Write a 4th method that will display the areas of all 3 shapes.

3. Your program Should have a main method that calls (invokes) the other 4 methods.

4. Test your program 3 times using the following data:

              L      W       B         H      R

1.         10     5       10       10    10

2.          5      1       12        3      5

3.          66   44     150    34    200