40 likes | 177 Vues
This guide provides an overview of Java’s Math class, focusing on essential methods like abs, pow, and sqrt, which allow basic mathematical operations. It includes a user input prompt to gather a full name, ensuring correctness by prompting for spaces. The program then analyzes the name by counting characters, displaying specific letters, converting to uppercase, checking for letters A and Z, and extracting initial letters. Additionally, a guide for calculating NFL QB ratings based on user input stats is included, reinforcing Java programming skills through practical examples.
E N D
Open Powerpoint 1.4 • Also open the assignment Middle
Java’s Math class • Allows you to do basic math functions • Not necessary to import it • 3 methods you must know: • Math.abs(num) // find the absolute value of num • Math.pow(base, exp) // raises base to the exp power • Math.sqrt(num) // finds the square root of num • Demo: MathDemo
Assignments • Review powerpoint 1.4, especially the substring example. • (Lettahs) Prompt the user to enter their full name (on one line, not separately). Then…. • If the user forgot to enter a space, make them try again until they get it right. • Display the number of characters in the name (not including the space). • Display the 1st letter, the 3rd letter, and the last letter (of the full name). • Display the name in all caps. • If the letters A and Z are both in the name, display “both.” • Display the characters from index #4 to (and including) index #6 • Display the characters from index #2 to the end of the name • Display the person’s initials only. • (QBrating) Click here for the NFL QB Rating Formula. (Take note of the line “a, b, c, and d can not…) Also, look up any NFL QB’s 2013 stats (completions, attempts, yards, TDs, and INTs). Then, write a program that asks the user for those 5 stats, and displays the correct QB rating.