Assignment 1: First Programs!

Due Friday, February 26, before midnight

The goals of this assignment are:

  • Work with string input and output

  • Work with variables, expressions and operations

  • Get comfortable with int, double, and String

1. Menu generator

credit: Sara Mathieson

You are in charge of writing a script for the daily specials at a new restaurant in Swarthmore: Corner Cafe. In Menu.java, write a program that will ask the restaurant for three pieces of information: the soup of the day, the special of the day, and the dessert of the day. Your program should then use this information to generate a short description of the daily specials (i.e. a restaurant [madlib](https://en.wikipedia.org/wiki/Mad_Libs)).

Here are two examples (user input in bold):

$ java Menu.java
Soup: wild rice
Special: salmon
Dessert: peach cobbler

Welcome to Corner Cafe!
Our soup of the day is wild rice.
The special tonight is salmon,
and for dessert, try our world-famous peach cobbler.

$ java Menu.java
Soup: cup noodles
Special: pizza
Dessert: M&Ms

Welcome to Corner Cafe!
Our soup of the day is cup noodles.
The special tonight is pizza,
and for dessert, try our world-famous M&Ms.

2. Cakes for sale

Write a program called Cakes.java that computes the price of a cake for the famous bakery Artisanal Squares. This bakery makes exclusive square cakes, with prices proportional to the area.

$ java Cakes.java
What is the cake width? 3
What is the cake height? 4.5
What is the cost per square inch? 3
The cake cost is $40.5

3. Calculator

Write a program, Calculator.java that asks the user for two numbers and returns the sum, difference, product, and division of them.

$ java Calculator.java
Enter the first number: 3.5
Enter the second number: 9.1

3.5 * 9.1 = 31.849999999999998
3.5 / 9.1 = 0.38461538461538464
3.5 + 9.1 = 12.6
3.5 - 9.1 = -5.6

4. What to hand-in

  1. The programs, Menu.java, Cakes.java, and Calculator.java.

  2. Make sure each program has a header containing your name, date, and purpose of the program

  3. A brief write-up containing your name, assignment number, and a few sentences about how long you spent on the assignment, any customizations you made, and any interesting bugs you solved.

4.1. How to hand-in

  1. Copy your programs to your dropbox, into the folder called A1.