View the step-by-step solution to:

COMP 274 ---- Homework 2 Name: Grade: Question 1: (20 points) Write a method to determine the largest number in 7 numbers. You can use the following...

I really need help here please??

COMP 274 ---- Homework 2 Name: Grade: Question 1: (20 points) Write a method to determine the largest number in 7 numbers. You can use the following methods. int larger(int a, int b) { if (a > b ) { return a; } return b; } int largestInFive(int a, int b, int c, int d, int e) { int temp1 = larger(a, b); int temp2 = larger(c, d); int temp3 = larger(temp1, temp2); return larger(temp3, e); } static int largestInSeven(int a, int b, int c, int d, int e, int f, int g) { // the implimentation. ..... }
Background image of page 1
Question 2: (20 points) Write a method to change the temperature from Celsius to Fahrenheit. The signature of the method is given as below. static double celsiusToFahrenheit(double C) { // the formula is F = (9/5)*C+32 } Question 3: (20 points) Write a method to calculate the salary of the employee. If the work hours are less than or equal to 40 hours, the salary = hours * rate. However, if the hours are over 40 hours, the extra hours will be paid by 1.5* rate. The signature of the method is given as below. static double getSalary(double hours, double rate) { } Question 4: (20 points) Given an int array, write a method to count the number of even numbers in the array. static int numOfEvenNumber(int[] arr) { //your implemention } Question 5: (10 points) 5.1 What is the difference between static fields and ordinary fields (i.e., the fields without static)? 5.2 What is the difference between static methods and ordinary methods (i.e., the methods without static)? Question 6: (10 points) What is constructor? What is the function of the constructor?
Background image of page 2
Show entire document
Sign up to view the entire interaction

Top Answer

PFA solution.... View the full answer

Assignment Programming 13314.docx

Question 1:
Write a method to determine the largest number in 7 numbers. You can use the
following methods.
import java.util.Scanner;
public class largestInSeven
{
static int larger(int m, int n)...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online