Question: 6.2 Sum the digits in an integer Write a method that computes the sum of the digits in an integer. Use the following method header:

6.2 Sum the digits in an integer Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(long n) For example, sumDigi ts(2 34) returns 9 (2 + 3 + 4). (Hint: Use the % opera-tor to extract digits, and the / operator to remove the extracted digit. For instance, to extract 4 from 234, use 234 % 10 4). To remove 4 from 234, use 234 / 10 (= 23). Use a loop to repeatedly extract and remove the digit until all the digits are extracted. Write a test program that prompts the user to enter an integer and displays the sum of all its digits. 6.8 Conversions between Celsius and Fahrenheit Write a class that contains the following two methods: Convert from Celsius to Fahrenheit public static double celsiusToFahrenheit(double celsius) Convert from Fahrenheit to Celsius */ public static double fahrenheitToCelsius(double fahrenheit) The formula for the conversion is: fahrenheit = (9.0 / 5) * celsius + 32 celsius = (5.0 / 9) * (fahrenheit - 32) 6.11 Write a test program that invokes these methods to display the following tables: Celsius Fahrenheit Fahrenheit Celsius 40.0 104.0 | 120.0 48.89 39.0 102.2 | 110.0 43.33 32.0 89.6 | 40.0 4.44 31.0 87.8 | 30.0 -1.11 6.18 Check password Some websites impose certain rules for passwords. Write a method that checks whether a string is a valid password. Suppose the password rules are as follows: - A password must have at least eight characters. - A password consists of only letters and digits. - A password must contain at least two digits. Write a program that prompts the user to enter a password and displays Val id Password if the rules are followed or Invalid Password otherwise.

NEEED ASAP PLEASE AND THANK YOU PROGRAMMING LANGUAGE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!