Lab 2

Purpose

This lab for you introduces some of the basic components of the Java programming language. It is essential to master these concepts because they will be used time and time again in future lab assignments.

Key Reading

  • 2.1-2.6
  • 3.1-3.2

Requirements

Part 1 - The Secret of Binary (7 points)

  • Write a Java application that will:
    • accept an integer from the user between 0 and 31
    • display the number to the screen as a base-ten number
    • display the number to the screen as a five-digit binary number.

  • Notes:
    - You may not use a predefined method in Java that converts decimal numbers to binary to complete this part; you must use your own algorithm.
    - Assume the user always enters a number between 0 and 31.

Part 2 - Temperature Conversion (6 points)

  • Write a Java application that will:
    • prompt the user to enter a temperature in degrees Fahrenheit
    • store the temperature input as a double
    • display the temperature in degrees Fahrenheit as an int
    • display the temperature in degrees Celsius as a double
    • display the temperature in degrees Celsius as an int.

Part 3 - BYU Fight Song (7 points)

  • Write a Java application that will:
    • display the entire BYU Fight Song
    • print the indices of the first lowercase 'b', 'y', and 'u' in the BYU fight song (3 separate indices)
    • display the length of the BYU fight song (in number of characters)
    • display the entire BYU Fight Song with all uppercase letters
    • assume that Orson Pratt was the second president of the Church (change all 'b's to 'o's and 'y's to 'p's, both upper and lower case characters)
    • display the OPU fight song
    • display the index of the first "OPU" in the OPU fight song (all three together).
  • Click here to view the BYU Fight Song.
Designed by Andy Griffin