QuestionQuestion

* Einstein’s famous formula E = MC2 gives the amount of energy released by the complete conversion of matter of mass M into energy E. If M represents the mass in kilograms and C represents the speed of light in meters per second (3.0 * 108 m/s), then the result is in the energy unit Joules. It takes 36000 Joules to light a 100 watt light bulb for an hour. Write a Java program that calculates the energy and the number of light bulbs that could be powered by a given mass of matter. Input a double value from the keyboard, and use scientific notation (E notation) and printf statements. Output should look similar to below.

Sample Run:
Enter the mass in kg: 0.01
This mass could provide 9E+14 Joules of energy.
It could power 2.5E+09 100 watt light bulbs for an hour.

* Angles are often measured in degrees (°), minutes ('), and seconds ("). There are 360 degrees in a circle, 60 minutes in one degree, and 60 seconds in one minute. Write a Java program that reads two angular measurements given in degrees, minutes, and seconds, and then calculates and displays their sum. Format the output with appropriate symbols (°,',").

Output should look similar to below.
Note: Use Unicode values for the symbols.

Sample Runs:
Enter the degrees: 74
Enter the minutes: 29
Enter the seconds: 13
2
Enter the degrees: 105
Enter the minutes: 8
Enter the seconds: 16
The sum of the angles: 179°37'29"
Enter the degrees: 20
Enter the minutes: 31
Enter the seconds: 19
Enter the degrees: 0
Enter the minutes: 31
Enter the seconds: 30
The sum of the angles: 21°2'49"
Enter the degrees: 122
Enter the minutes: 17
Enter the seconds: 48
Enter the degrees: 237
Enter the minutes: 42
Enter the seconds: 12
The sum of the angles: 0°0'0"

* Have you heard of the Fizz Buzz problem? Some businesses claim they interview Computer Science graduates they can't solve the Fizz Buzz problem. Write a Java program that prints asks the user to enter a positive value (1 less than or equal to 200) and print each number up to that line, 1 per line with the following changes (SNAP CRACKLE POP).
• If a number is divisible by 2 (but not 3 or 5) print out SNAP instead of the integer.
• If a number is divisible by 3 (but not 2 or 5) print out CRACKLE instead of the integer.
• If a number is divisible by 5 (but not 2 or 3) print out POP instead of the integer.
• If a number is divisible by 2 and 3 (but not 5) print out SNAPCRACKLE instead of the integer.
• If a number is divisible by 2 and 5 (but not 3) print out SNAPPOP instead of the integer.
• If a number is divisible by 3 and 5 (but not 2) print out CRACKLEPOP instead of the integer.
• If a number is divisible by 2, 3, and 5 print out SNAPCRACKLEPOP instead of the integer.

Error check inputs. Output should look similar to below.
3

Sample Runs:
Enter a positive value: 7
1
SNAP
CRACKLE
SNAP
POP
SNAPCRACKLE
7

Enter a positive value: 10
1
SNAP
CRACKLE
SNAP
POP
SNAPCRACKLE
7
SNAP
CRACKLE
SNAPPOP

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class DisplayLeapYears {
   
    public static void main(String[] args) {
       boolean isLeapYear;
       int i = 0;
       for (int year = 101; year <= 2100; year++) {
            isLeapYear = (
                        year % 4 == 0 &&
                        year % 100 != 0
                   ) ||
                   ( year % 400 == 0 );
            if (isLeapYear) {
                System.out.printf("%6d", year);
                i++;
            }      
            if (i == 10) {
                System.out.printf("%n");
                i = 0;...
$38.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats