Graderpractice for programmers

254275 OOP - Midterm 2562 2/2563

Awaiting submission
Midterm Q6. Complete the code by writing a function that calculates the ​average​ marks.

Test code:

class Q1 
{
 
     public static void main (String[] args) 
      {
         double [] marks = { 2.0, 5.0, 3.0, 4.0 }; 
	 double average = averageMark(marks); 
	 System.out.println(average); 

      }
}
 

Awaiting submission
Q2.
Midterm Q7. Complete the code
public static void​ main(String[] args){
    for​ (​int​ i=0;i<5;i++){
       ...................................................................................................
       ...................................................................................................
       ..................................................................................................
    }
 }
Awaiting submission
Q3.
Midterm Q8. Write a program that inputs a number ​x​ and outputs the sum of ​1 + 2 + ... + x​.
Awaiting submission
Q4.
Midterm Q9. Write a program that reads in a list of words and outputs the shortest word.