Usetutoringspotscode to get 8% OFF on your first order!

  • time icon24/7 online - support@tutoringspots.com
  • phone icon1-316-444-1378 or 44-141-628-6690
  • login iconLogin

Introduction to Programming with Java

Introduction to Programming with Java

Question One: [10 marks]

a. Write a Java class (program) that reads from the user a real number represents the length of the hypotenuse of an isosceles right triangle. Then calculates and prints the area of this triangle (rounded to 2 decimal places). [9 marks] Hint: You can search the internet to discover how to calculate the area of

an isosceles right triangle when you only know the length of its hypotenuse.

b. Give the exact output of your program. Provide a snapshot representing the exact output of any value from your choice. [1 mark]

Question Two: [24 marks]

a. For any quadratic equation: , there are zero, one or two real solutions. Write a Java application that reads from the user 3 integers represent the values of the coefficients of a quadratic equation (a, b and c). Then computes and prints how many real solutions for the given equation. In addition, if the user enters 0 as the value of a, a suitable error message should be displayed and nothing should be computed. [20 marks]

Hints:

ï‚· It is not required to compute the real solutions. Just compute number of them.

ï‚· You can search the internet to discover when a quadratic equation has zero, one or two real solutions.

b. Give the exact output of your application. Give 4 snapshots representing the exact output of 4 different cases (i.e., when the number of real solutions is 0, 1, 2 and when the user enters 0 as the value of a). [4 marks]

3

Question Three: [21 marks]

a. Assume that a tutor created a 5-mark quiz for his students and he wants to know the mode of students’ scores in the quiz. Write a Java program that reads from the user 6 lines of input. Each line includes 2 integers: a score and number of students who got this score. The program should compute and print the mode of students’ scores (You can assume that there is always a unique answer) [19 marks]

b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [2 marks]

Hints:

ï‚· You can search the internet to discover how to compute the mode.

ï‚· The input and output of your program should be exactly as in the sample below

Sample Input and Output: Please, insert the scores and the frequency of each score: 0 1 1 0 (This line means that no student got 1 out of 5) 2 6 3 9 4 7 (This line means that 7 students got 4 out of 5) 5 4 The mode of students’ scores is 3

Question Four: [25 marks]

a. Write a Java program that read your first name and the first names of your friends. Then the program should compute and prints the percentage of your friends whose first names start with the same letter as your first name (rounded to 2 decimal places). Enter the word “stop” to stop the program. [24 marks]

b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 marks]

Hint:

The input and output of your program should be exactly as in the sample below

Sample Input and Output: Please, insert your first name: Ahmad Please, insert the first names of your friends (enter “stop” to stop your program): Hisham Ali Nader stop 33.33% of your friends their first names start with the same letter as your first name

Explanation: There are 3 friends, 1 of them his first name starts with the same letter as your first name. 1 out of 3 represents 33.33% of your friends ( ).

End of Assessment

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Introduction to Programming with Java

Introduction to Programming with Java

Question One: [10 marks]

a. Write a Java class (program) that reads from the user a real number represents the length of the hypotenuse of an isosceles right triangle. Then calculates and prints the area of this triangle (rounded to 2 decimal places). [9 marks] Hint: You can search the internet to discover how to calculate the area of

an isosceles right triangle when you only know the length of its hypotenuse.

b. Give the exact output of your program. Provide a snapshot representing the exact output of any value from your choice. [1 mark]

Question Two: [24 marks]

a. For any quadratic equation: , there are zero, one or two real solutions. Write a Java application that reads from the user 3 integers represent the values of the coefficients of a quadratic equation (a, b and c). Then computes and prints how many real solutions for the given equation. In addition, if the user enters 0 as the value of a, a suitable error message should be displayed and nothing should be computed. [20 marks]

Hints:

ï‚· It is not required to compute the real solutions. Just compute number of them.

ï‚· You can search the internet to discover when a quadratic equation has zero, one or two real solutions.

b. Give the exact output of your application. Give 4 snapshots representing the exact output of 4 different cases (i.e., when the number of real solutions is 0, 1, 2 and when the user enters 0 as the value of a). [4 marks]

3

Question Three: [21 marks]

a. Assume that a tutor created a 5-mark quiz for his students and he wants to know the mode of students’ scores in the quiz. Write a Java program that reads from the user 6 lines of input. Each line includes 2 integers: a score and number of students who got this score. The program should compute and print the mode of students’ scores (You can assume that there is always a unique answer) [19 marks]

b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [2 marks]

Hints:

ï‚· You can search the internet to discover how to compute the mode.

ï‚· The input and output of your program should be exactly as in the sample below

Sample Input and Output: Please, insert the scores and the frequency of each score: 0 1 1 0 (This line means that no student got 1 out of 5) 2 6 3 9 4 7 (This line means that 7 students got 4 out of 5) 5 4 The mode of students’ scores is 3

Question Four: [25 marks]

a. Write a Java program that read your first name and the first names of your friends. Then the program should compute and prints the percentage of your friends whose first names start with the same letter as your first name (rounded to 2 decimal places). Enter the word “stop” to stop the program. [24 marks]

b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 marks]

Hint:

The input and output of your program should be exactly as in the sample below

Sample Input and Output: Please, insert your first name: Ahmad Please, insert the first names of your friends (enter “stop” to stop your program): Hisham Ali Nader stop 33.33% of your friends their first names start with the same letter as your first name

Explanation: There are 3 friends, 1 of them his first name starts with the same letter as your first name. 1 out of 3 represents 33.33% of your friends ( ).

End of Assessment

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes