Question

In: Computer Science

I am having problems making code to follow these parameters. 1. Create a new project and...

I am having problems making code to follow these parameters.

1. Create a new project and class in Eclipse. (5 points)

2. Add a comment with your name(s) on the first line of your code. (5 points)

3. Add the main method to the class. (5 points)

4. Use variables to store three book titles and their authors. (10 points)

5. Use variables to store the price of each book. (10 points)

6. Use variables to store the number of copies purchased of each book. (10 points)

7. Use a constant variable to store the tax rate (8.75%). (5 points)

8. Calculate the pretax total, sales tax, and total order cost using arithmetic operators and the variables described above. Store the calculation results in variables. (20 points)

9. Print the order information to the console. When printing dollar amounts, round each value to two decimal places (i.e., to the nearest penny). (20 points)

10. Use meaningful variable names, consistent indentation, and whitespace (blank lines and spaces) to make your code readable. Add comments where appropriate to explain the overall steps of your program. (10 points)

Solutions

Expert Solution

import java.util.Scanner;

/**
* @author Name
*
*/
public class BookOrder {
   public static void main(String[] args) {
       // variables for titles
       String title1, title2, title3;
       // variables for authors
       String author1, author2, author3;
       // variables for prices
       double price1, price2, price3;
       // variables for units
       int units1, units2, units3;
       //constant to store tax rate
       final double TAX_RATE = 8.75;
       double preTaxTotal, salesTax, total;
       Scanner sc = new Scanner(System.in);
       //reading book1 details
       System.out.println("Enter title and author of book 1");
       title1 = sc.nextLine();
       author1 = sc.nextLine();
       System.out.println("Enter the number of units for book");
       units1 = sc.nextInt();
       System.out.println("Enter price for book 1");
       price1 = sc.nextDouble();
       //reading book2 details
       System.out.println("Enter title and author of book 2");
       title2 = sc.nextLine();
       title2 = sc.nextLine();
       author2 = sc.nextLine();
       System.out.println("Enter the number of units for book2");
       units2 = sc.nextInt();
       System.out.println("Enter price for book 2");
       price2 = sc.nextDouble();
       //reading book3 details

       System.out.println("Enter title and author of book 3");
       title3 = sc.nextLine();
       title3 = sc.nextLine();
       author3 = sc.nextLine();
       System.out.println("Enter the number of units for book 3");
       units3 = sc.nextInt();
       System.out.println("Enter price for book 3");
       price3 = sc.nextDouble();

       //finding preTaxtotal and sales tax and total amount
       preTaxTotal = price1 * units1 + price2 * units2 + price3 * units3;
       salesTax = preTaxTotal * (TAX_RATE / 100);
       total = preTaxTotal + salesTax;
       System.out.println("Pre Tax Amount : " + preTaxTotal);
       System.out.println("Sales Tax Amount (" + TAX_RATE + "%): " + salesTax);
       System.out.println("Total Amount : " + total);

   }
}


Related Solutions

I am having an issue with the code. The issue I am having removing the part...
I am having an issue with the code. The issue I am having removing the part when it asks the tuter if he would like to do teach more. I want the program to stop when the tuter reaches 40 hours. I believe the issue I am having is coming from the driver. Source Code: Person .java File: public abstract class Person { private String name; /** * Constructor * @param name */ public Person(String name) { super(); this.name =...
I have a project due and am having problems compiling a program: The only program I...
I have a project due and am having problems compiling a program: The only program I have written is check.c everything else is given and correct. Can you modify check.c to simply print out the chessboard, in other words, to get it to compile by any means thank you. The only thing you have to modify again is check.c nothing else. Just get it to print something thanks. program chess.c #include #include #include "chess.h" void get_valid_move(int mover) { int x_from,...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize these entries and post the closing entries 2. i need to prepare Dalhanis multi-step income statement and statement of owners equity for August 2010 3. i need to prepare the blance sheet at august 31,2010 4. i need to prepare a post-closing trial balance at august 31,2010 DALHANI makes all credit sales on terms 2/10 n/30 and uses the Perpetual Inventory System Aug 1...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize these entries and post the closing entries 2. i need to prepare Dalhanis multi-step income statement and statement of owners equity for August 2010 3. i need to prepare the blance sheet at august 31,2010 4. i need to prepare a post-closing trial balance at august 31,2010 DALHANI makes all credit sales on terms 2/10 n/30 and uses the Perpetual Inventory System Aug 1...
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
Hi I am having the following problem. At the moment I am trying to create a...
Hi I am having the following problem. At the moment I am trying to create a bode plot for the following function. G(s)=(Ks+3)/((s+2)(s+3)) Note: Not K(s+2)! I then want to plot multiple bode plots for various values of K. Eg. 1,2,3, etc. I am having two separate issues. 1. How do I define the TF with a constant K in the location required (a multiple of s in the numerator) 2. How do I create multiple bode plots for values...
I am having problems getting the second button part of this to work. this is for...
I am having problems getting the second button part of this to work. this is for visual basic using visual studio 2017. Please help. Create an application named You Do It 4 and save it in the VB2017\Chap07 folder. Add two labels and two buttons to the form. Create a class-level variable named strLetters and initialize it to the first 10 uppercase letters of the alphabet (the letters A through J). The first button’s Click event procedure should use the...
I am having problems with : If 6 is selected, then you will get an employee...
I am having problems with : If 6 is selected, then you will get an employee pay amount from the user. This will be a double. Only allow them to enter one pay amount and then display the main menu again. AND: if 2 is selected you will promt the user for a grade (double) from 0-100. Only allow them to enter one grade and then display the main menu again The project: Create a project called P03. Inside of...
I am having trouble with a C++ code that I'm working on. It is a spell...
I am having trouble with a C++ code that I'm working on. It is a spell checker program. It needs to compare two arrays, a dictionary, and an array with misspelled strings that are compared to the strings in the dictionary. the strings that are in the second array that is not in the Dictionary are assumed to be misspelled. All of the strings in the dictionary are lowercase without any extra characters so the strings that are passed into...
I am currently having trouble understanding/finding the errors in this python code. I was told that...
I am currently having trouble understanding/finding the errors in this python code. I was told that there are 5 errors to fix. Code: #!/usr/bin/env python3 choice = "y" while choice == "y": # get monthly investment monthly_investment = float(input(f"Enter monthly investment (0-1000):\t")) if not(monthly_investment > 0 and monthly_investment <= 100): print(f"Entry must be greater than 0 and less than or equal to 1000. " "Please start over.")) #Error 1 extra ")" continue # get yearly interest rate yearly_interest_rate = float(input(f"Enter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT