1. What type of variables would hold the following data? (int, double, String char)
2. For each of the descriptions in part 1, what method from the IBIO class would be needed to input a value into the variable? (IBIO.inputString, IBIO.inputChar, IBIO.inputInt, IBIO.inputDouble)
3. For each of the description in part 1, what would be a good variable name?
4. Declare a variable, and use IBIO to get the following information. eg. String name = IBIO.inputString("Enter your name:");
(a) the length of a side of a square
(b) the
total price of a shirt
(c) the
tax rate
(d) the
answer to “Do you want to continue(y/n):”
(e) a menu:
Pick one of:
1. Introduction
2. Argument
3. Conclusion
4. Recommendation
5. Quit
(f) the first letter of the user’s name
5. Write programs to do the following:
(a)
Ask the user the length of the side of a square and output its area
(b) Ask the user for their favourite letter and then output a line of 20 of
them
(c) Ask the user for the height and base of a triangle and calculate its area
(d) Prints a menu, asks for a selection and then repeats the number chosen to
the screen. (eg of repeat: You have choosen 6)
6. Which line has an example of each of the following: (look at your code file for examples)
Debugging and Variables - A Short Exercise
Question 6: There are 5 distinct errors in the following java program, what
are they?
import java.io //line1public class //line2
{ //line 3
public static main (String args[]) //line 4
{ int h; //line 5
h=IBIO.inputDouble("Please enter a decimal:"); //line 6
System.out.println(num); //line 7
} //line 8
} //line 9
Question 7. Which type of variable is used for each of the following situations?
(int, double, char, String)
(a) To hold a person's name
(b) To hold the answer to "Enter the first letter of your name"
(c) The hold the price of a hamburger
(d) To hold the number of students in a class
(e) To hold the answer to "Is this correct (y/n)?"
(f) To hold the amount of tax on a purchase
(g) To hold the mark someone got on a test
(h) To hold the number of fish in a tank
(i) To hold the day of the month
(k) To hold "Turner Fenton"