Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you write the codes for the 3 task in the images I provided? The images are in page order. MAC190 In-Class Assignment #1 January

Can you write the codes for the 3 task in the images I provided? The images are in page order. image text in transcribedimage text in transcribedimage text in transcribed

MAC190 In-Class Assignment #1 January 05, 2021 Due: 01/06/2021 Task # 1 Initialize and print more variables 1-Within a main method, initialize String variables for your first and last name. Then, print these String variables to the console in this format: Name: lastname, Firstname 2-Run the application 3-Add an assignment statement that changes the value of the variable for the firstname. 4-Run the application (print to the console) Task# 2 Work with arithmetic expressions 1-Declare and initialize a double variable that stores a sum and an int variable that stores a count. 2-Calculate an average by dividing the sum variable by the count variable. Then, assign the result of the calculation to the average variable and print it to the console. When you are done, the console should look like this: Sum: 301.75 Count: 6 Average: 50.29166666666666664 3-Run the application 4-Add an assignment statement that changes the value for the sum variable 5-Run the application (print to the console for the sum and average) Task # 3 Calculate tax and grand total * Author: Peter pan * Purpose: This application displays some text on the console. It can be use as starting point for testing code. * Date: January 03, 2021 */ public class First Program { public static void main(String[] args) { // TODO Auto-generated method stub //Display welcome message //Display a welcome message System.out.println("Welcome to the MAC190 Class"); System.out.println(); // hard code three variables String product Code = "Java"; double price = 14.95; int quantity = 2; //perform a calculation double total = price * quantity; //Display the output String message = "Code: + product Code + " " + "Price: " + price + " " + "Quantitiy: " + quantity + " " + "Total: + total + " "; System.out.println(message); //display a good bye message System.out.println("Bye!"); } } 1-Modify the starting code as described: Code: android Description: Programming Price: 57.5 Quantity: 2 Total: 115.0 Tax Percent: 7.5 Tax Amount: 8.625 Grand Total: 123.625 2-Declare and initialize a String variable for the product description 3-Declare and initialize a double variable for the tax percent. Use the value.075, which is 7.5% 4-Declare and initialize a double variable for the tax amount. Then, calculate the amount by multiplying the total by the tax percent and assign the result to the variable. 5-Declare and initialize a double variable for the grand total. Then, calculate the grand total by adding the total and tax amount and assign the result to the variable. 6-Modify the string that displays the data to the application prints it to the console. To get the tax percent to display correctly, you can multiple it by 100. 7-Run the application

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions