Assignment 6

Due Thursday, February 1 at 11:20am on Canvas.

Assignment 6.1: Calculator Part 2 (10 pts)

  • We are going to create a calculator program using the math functions from the Math library.
  • Working by yourself, open a new project in Eclipse and name it Calculator with a new class known as
  • You should prompt the user to input a number.
  • Your calculator is going to perform the following operations on that number:
    • Raise the number to the power of 2, 3, and 4 (square, cube, quartic)
    • Calculate the floor of the number
    • Calculate the ceiling of the number
    • Calculate the square root of the number
  • Your program should give output as shown below.
  • When you are finished, upload your file to Canvas.
Your output should look identical to the following.
Enter a number: 2.5
The square of 2.5 is: 6.25
The cube of 2.5 is: 15.625
The quartic (fourth power) of 2.5 is: 39.0625
The ceiling of 2.5 is: 3.0
The floor of 2.5 is: 2.0
The square root of 2.5 is: 1.5811388300841898

Activity 6.2: Working with Strings (10 pts)
  • Open a new Java project named MyName in Eclipse
  • We will create a program to greet the user by name.
  • Add a block comment at the top of your program with your name and section information.
* Name
* Section info
  • At the top of the main method, let's declare our first String variable - to store the first name of our user:
String first_name;
  • Declare a second String variable to store the last name of our user in the same _ style.
  • Declare a third String variable to store the user's full name:
String full_name;
  • Finally, declare a new Scanner variable named input and connect it to the console keyboard.
  • Welcome the user with a statement like this one:
System.out.println("Hi! I want to learn your name!");
  • Now, prompt the user to enter their first name.
System.out.print("Please enter your first name: ");
  • Follow this prompt with a statement to capture the user input.
first_name =;
  • Now prompt the user to enter his or her last name and store the input in the last_name variable.
  • We want to assign the full_name variable the value of the user's first and last name combined. Let's do so now using concatenation:
full_name = first_name + " " + last_name;
  • Finally, let's greet the user by his or her full name.
System.out.println("Nice to meet you " + full_name + "!");

  • Lastly, close your Scanner
  • Run your program to ensure it is giving you the output you expect.
  • Upload your program to Canvas when you are finished.