Guest User

Untitled

a guest
Jan 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /*
  2. * This method will take in a first and last name and a hw average and a project average and finds the grade
  3. * The grade is made up of 40% hw, 60% projects. The name will be abbreviated as shown below
  4. * So if findGrade("Jeff", "Borland", 90, 80) would print out Student JB has a 84.0 in the class
  5. * The 84 is because 40%*90 + 80*.60 = 84.0
  6. */
  7. public void findGrade(String firstName, String lastName, double hw, double project)
  8. {
  9. String firstInitial = firstName.substring(0,1);
  10. String lastInitial = lastName.substring(0,1);
  11.  
  12. String abbreviatedName = firstInitial + lastInitial;
  13.  
  14. double homeworkGrade = hw * 0.4f;
  15. double projectGrade = project * 0.6f;
  16.  
  17. double finalGrade = homeworkGrade + projectGrade;
  18.  
  19. System.out.println(abbreviatedName + " has a " + finalGrade + " in the class");
  20. }
Add Comment
Please, Sign In to add comment