Import and edit the ShoppingCart02 project. • Declare and initialize numeric fields: – price (double) – tax (double) – quantity (int) • Declare a double totalPrice: – Assign a value, calculated from price , tax , and quantity. Change message to include quantity: – (example: “Alex wants to purchase 2 Shirts.”) • Print another message showing the total cost. Your program should produce a similar output: Alex wants to purchase 2 Shirts Total cost with tax is: $25.78 ShoppingCart02.java package shoppingcart02; public class ShoppingCart02 { public static void main(String[] args) { String custName = "Alex"; String itemDesc = "Shirts"; String message = custName+" wants to purchase a "+itemDesc; // Declare and initialize numeric fields: price, tax, quantity. // Declare and assign a calculated totalPrice // Modify message to include quantity System.out.println(message); // Print another message with the total cost } } Exercise 5 Import and edit the Casting01 project Casting01.java package casting01; public class Casting01 { public static void main(String[] args) { //Declare and initialize a byte with a value of 128 //Observe NetBeans or eclipse complaint //Declare and initialize a short with a value of 128 //Create a print statement that casts this short to a byte //Declare and initialize a byte with a value of 127 //Add 1 to this variable and print it //Add 1 to this variable again and print it again } } Exercise 6 Import and edit the Parsing01 project. • Declare and initialize 3 Strings with the following data: String Variable Description Example Values shirtPrice Text to be converted to an int: "15" taxRate Text to be converted to a double: "0.05" gibberish Gibberish "887ds7nds87dsfs" Parse and multiply shirtPrice*taxRate to find the tax. – Print this value. • Try to parse taxRate as an int. – Observe the error message. • Try to parse gibberish as an int. – Observe the error message. Parsing01.java package parsing01; public class Parsing01 { public static void main(String[] args) { //Declare and intitialize 3 Strings: shirtPrice, taxRate, and gibberish //Parse shirtPrice and taxRate, and print the total tax //Try to parse taxRate as an int //Try to parse gibberish as an int } }
Don't Copy from other website.
ALL THREE ANSWER PLZ
Exercise 4
Import and edit the ShoppingCart02 project.
• Declare and initialize numeric fields:
– price (double)
– tax (double)
– quantity (int)
• Declare a double totalPrice:
– Assign a value, calculated from price , tax , and quantity.
Change message to include quantity:
– (example: “Alex wants to purchase 2 Shirts.”)
• Print another message showing the total cost.
Your program should produce a similar output:
Alex wants to purchase 2 Shirts
Total cost with tax is: $25.78
ShoppingCart02.java
package shoppingcart02;
public class ShoppingCart02 {
public static void main(String[] args) {
String custName = "Alex";
String itemDesc = "Shirts";
String message = custName+" wants to purchase a "+itemDesc;
// Declare and initialize numeric fields: price, tax, quantity.
// Declare and assign a calculated totalPrice
// Modify message to include quantity
System.out.println(message);
// Print another message with the total cost
}
}
Exercise 5
Import and edit the Casting01 project
Casting01.java
package casting01;
public class Casting01 {
public static void main(String[] args) {
//Declare and initialize a byte with a value of 128
//Observe NetBeans or eclipse complaint
//Declare and initialize a short with a value of 128
//Create a print statement that casts this short to a byte
//Declare and initialize a byte with a value of 127
//Add 1 to this variable and print it
//Add 1 to this variable again and print it again
}
}
Exercise 6
Import and edit the Parsing01 project.
• Declare and initialize 3 Strings with the following data:
String Variable Description Example Values
shirtPrice Text to be converted to an int: "15"
taxRate Text to be converted to a double: "0.05"
gibberish Gibberish "887ds7nds87dsfs"
Parse and multiply shirtPrice*taxRate to find the tax.
– Print this value.
• Try to parse taxRate as an int.
– Observe the error message.
• Try to parse gibberish as an int.
– Observe the error message.
Parsing01.java
package parsing01;
public class Parsing01 {
public static void main(String[] args) {
//Declare and intitialize 3 Strings: shirtPrice, taxRate, and gibberish
//Parse shirtPrice and taxRate, and print the total tax
//Try to parse taxRate as an int
//Try to parse gibberish as an int
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps