Java Experts Sample Assignment.
Firstly;
- Define high-level languages, machine language and low-level language. Explain how the languages correspond to one another.
- What is byte-code? What is its importance?
- What is the syntax and semantics of a programming language?
- What steps must the programmer take to create an executable Java program?
- List the primitive data types Java supports. Indicate the kind of values each type can store. Java Experts Sample Assignment.
- How is the % (modulus) operator used? What is the common use of the modulus operator?
- Explain the difference between an implicit type cast and an explicit type cast.
- Write a Java statement to access the 7th character in the String variable myString and place it in the char variable c.
ORDER A CUSTOM-WRITTEN, PLAGIARISM-FREE PAPER HERE
- Write a Java statement to determine the length of a string variable called input. Store the result in an integer variable called strLength.
- Why is using named constants a good programming practice?
- How are line comments and block comments used?
What are the values of the variables a, b, c, and d after the execution of the following expressions?
int a = 3;
int b = 12;
int c = 6;
int d = 1;
d = d * a;
c = c + 2 * a;
d = d – b / c;
c = c * b % c;
b = b / 2;
What is the output produced by the following lines of code?
int value1 = 3;
int value2 = 4;
int result = 0;
result = value1++ * value2–;
System.out.println(“Post increment/decrement: ” + result);
Practical Exercise 1
Write a program that starts with the string variable first set to your first name and the string variable last set to your last name. Both names should be all lowercase. Your program should then create a new string that contains your full name in pig latin with the first letter capitalized for the first and last name. Use only the rule of moving the first letter to the end of the word and adding “ay”. Finally output the pig latin name to the screen. Use the subString and toUpperCase methods to construct the new name.
first = “walt”;
last = “savitch”;
would output “Altway Avitchsay”
Practical Exercise 2.
A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for each additional inch. Write a program with a variable for the height of a person in feet and another variable for the additional inches. Assume the person is at least 5 feet tall. For example a person that is 6 feet and 3 inches tall would be represented with a variable that stores the number 6 and another variable that stores the number 3. Based on these values, calculate and output the ideal body weight. Java Experts Sample Assignment.
- Write a Java statement to display your name in the console window.
- Write ONE Java statement to display your first and last name on two separate lines.
- Write Java statements to apply currency formatting to the number 100. Indicate the package you need to import.
- Write a Java program to create and display 57.32% using the DecimalFormat class. Include the necessary import statement to use the DecimalFormat class.
- Explain the significance of the pattern string used by the DecimalFormat object, and give an example of a valid pattern.
- What does it mean to prompt the user?
- Why is echoing user input a good programming practice?
- If there is no loss of efficiency in importing an entire Java package instead of importing only classes you use into your program, why would you not just import the entire package?
- Discuss the differences between the break and the continue statements when used in looping mechanisms.
- Write a complete Java program that prompts the user for a series of numbers to determine the smallest value entered. Before the program terminates, display the smallest value.
- Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 25.
- What is short-circuit evaluation of Boolean expressions?
- Discuss the rules Java follows when evaluating expressions. Java Experts Sample Assignment.
- Write Java code that uses a do while loop that prints even numbers from 2 through 10.
- Write Java code that uses a while loop to print even numbers from 2 through 10.
- What is a sentinel value and how is it used?
- Write Java code that uses a for statement to sum the numbers from 1 through 50. Display the total sum to the console.
- What is the output of the following code segment?
ORDER A CUSTOM-WRITTEN, PLAGIARISM-FREE PAPER HERE
public static void main(String[] args) {
int x = 5;
System.out.println(“The value of x is:” + x);
while(x > 0) {
x++;
}
System.out.println(“The value of x is:” + x);
}
Practical Exercises on Console IO
(To Be Done In Practical With Partner)
Practical Exercise 1.
The straight line method for computing the yearly depreciation in value D for an item is given by the following formula:
D = (P – S)/Y
Where P is the purchase price, S is the salvage value, and Y is the number of years the item is used. Write a program that takes as input the purchase price of an item, the expected number of years of service, and the expected salvage value. The program should then output the yearly depreciation for the item.Java Experts Sample Assignment.
Practical Exercise 2.
Create a text file (using Eclipse) that contains the text “I hate typing up stuff from the textbook”. Write a program that reads in this line of text from the file. The word hate is changed to love and output to the screen. This should handle any sentence containing hate and should handle the first incidence of hate.
Some Hints:
You will need to use some skills you have not got yet.Java Experts Sample Assignment.