Question

In: Computer Science

I have the problem in bold below. I am completely confused. I am hoping that I...

I have the problem in bold below. I am completely confused. I am hoping that I will see how you did this and will be able to follow it. Please remember that I have just started this so please don't use any complex features that an absolute beginner (like me) wouldn't know.

Additional information:

  /*This is what everyone owes before tax and tip:

    Person 1: $10

    Person 2: $12

    Person 3: $9

    Person 4: $8

    Person 5: $7

    Person 6: $15

    Person 7: $11

    Person 8: $30

    */

package Tip02;

public class Calculator {

  public double tax = .05;

  public double tip = .15; //Change tax and tip if you prefer different values

  public double originalPrice = 0;

   

  public void findTotal(){

    //Calculate an individual's total after tax and tip

    //Print this value

  }

}

Please give me a solution and (explanation if possible).

Package Tip02;

public class CalculatorTest {

  public static void main(String[] args) {

    //Instantiate a Calculator object

    Calculator calc = new Calculator ();

    

     //Access the Calculator object's fields and methods

    //to find the total for each member of the birthday party

         /*This is what everyone owes before tax and tip:

    Person 1: $10

    Person 2: $12

    Person 3: $9

    Person 4: $8

    Person 5: $7

    Person 6: $15 (Alex)

    Person 7: $11

    Person 8: $30

    */

     

  }

}

Solutions

Expert Solution

input code:

package:

Main file:

output:

code:

package:

package Tip02;
class Calculator {
/*declare the variables*/
public double tax = .05;
public double tip = .15; //Change tax and tip if you prefer different values
public double originalPrice = 0;
/*find Total method*/
public void findTotal()
{
/*find and print Total*/
System.out.println(" Total = "+String.format("%.2f",(originalPrice+originalPrice*tax+originalPrice*tip)));
}

}

main file:

import Tip02;

public class CalculatorTest {

public static void main(String[] args) {
  
/*make Calculator object*/
Calculator calc = new Calculator ();
/*for Person 1 Calculate total bill*/
System.out.print("Person 1");
/*set value of originalPrice*/
calc.originalPrice=10;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 2 Calculate total bill*/
System.out.print("Person 2");
/*set value of originalPrice*/
calc.originalPrice=12;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 3 Calculate total bill*/
System.out.print("Person 3");
/*set value of originalPrice*/
calc.originalPrice=9;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 4 Calculate total bill*/
System.out.print("Person 4");
/*set value of originalPrice*/
calc.originalPrice=8;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 5 Calculate total bill*/
System.out.print("Person 5");
/*set value of originalPrice*/
calc.originalPrice=7;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 6 Calculate total bill*/
System.out.print("Person 6");
/*set value of originalPrice*/
calc.originalPrice=15;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 7 Calculate total bill*/
System.out.print("Person 7");
/*set value of originalPrice*/
calc.originalPrice=11;
/*call findTotal method*/
calc.findTotal();
  
/*for Person 8 Calculate total bill*/
System.out.print("Person 8");
/*set value of originalPrice*/
calc.originalPrice=30;
/*call findTotal method*/
calc.findTotal();
  
}

}


Related Solutions

The Question I am needing assistance with is in BOLD BELOW. I will include the other...
The Question I am needing assistance with is in BOLD BELOW. I will include the other aspects of this assignment for reference, as well as the table used/needed for these calculations. Option #1: Critical Thinking: Quality at A1 Hotels A1 Hotels operates luxury hotels throughout the world. Recently, motivated by some incidents that appeared in the news, they have been concerned about the quality of service. The company has been giving the following survey to its clients after their stay:...
I am confused with the end replication problem. So, at the end DNA polyermase III is...
I am confused with the end replication problem. So, at the end DNA polyermase III is unable to bind to the end because there is a missing of a 3' hydroxyl group. Given that, why can't a DNA primase simply add a primer at the end in which DNA polymerase III binds to it and finishes the replication and then a DNA polymerase I binds to the primer and replaces it with DNA and therefore solving the problem? Can someone...
I have a question about C++ programming Language class. I am confused with these terms and...
I have a question about C++ programming Language class. I am confused with these terms and what they are for. 1. Unix 2. Terminal 3. Git 4. CLOC 5. Linux Please explain each words and what's their jobs for C++. Also, if you know some good sources/websites, could you please provide me a link where I can learn how to use Unix, Terminal, Git, etc.
I am getting confused on finding the ethical challanges to this question. I am understanding but...
I am getting confused on finding the ethical challanges to this question. I am understanding but second guessing my answers when it come to the elements and the Ethical Code Standards. 1. Identify an ethical challenge for each element (a-d) of Dr Lux advertising plan. Which General Principles and Ethical Code Standards best help understand why these elements may create ethical problems? Explain why. Case 5. Web-Based Advertising. Dr. Lux, an applied developmental psycholgoist, has created his own community consulation...
I am working on extensive report for my Advanced Corp. Tax class and I am hoping...
I am working on extensive report for my Advanced Corp. Tax class and I am hoping to get a better understanding of the following: -In order for a corporation to make a valid “S” election, the corporation must be a “small business corporation.” Explain the meaning of “small business corporation” in this context. -Explain what ‘separately stated items’ are in regards to Partnerships and S corporations? Give an example of ‘separately stated items’ for each type of entity. -What requirements...
Hello, I am studying and I am a bit confused about registers. There are segments registers,...
Hello, I am studying and I am a bit confused about registers. There are segments registers, data registers, pointer registers, index registers. But I do not really understand where these are found. Are they found in 8086 architecture? For instance if I ask what type of registers are found in 8086 architecture what will be the answer? All of these or only segment registers?
The Table in my homework question below is completely wrong. I am not sure where I...
The Table in my homework question below is completely wrong. I am not sure where I went wrong in my calculations but coud you rework this question and answer the parts below?? Here are earnings per share for two companies by quarter from the first quarter of 2009 through the second quarter of 2012. Forecast earnings per share for the rest of 2012 and 2013. Use exponential smoothing to forecast the third period of 2012, and the time series decomposition...
I am given the following problem and solution. Can someone just explain where the BOLD values...
I am given the following problem and solution. Can someone just explain where the BOLD values in part B are coming from? ($60,000,000, $80,000,000, $200,000,000) [Relative Value Concepts Using Multiples] The WestTek privately held venture is considering the sale of the venture to an outside buyer. WestTek has net sales = $21.2 million, EBITDA = $11.1 million, net income = $2.9 million, and interest-bearing debt = $12 million. Three publicly-traded comparable firms or competitors in the industry have the following...
Hi I am working on my chemistry homework about acids and bases and I am confused...
Hi I am working on my chemistry homework about acids and bases and I am confused on this question from a lab. We used grape juice and cranberry juice and we had to put HCl and NaOH in the test tube full of juice. 1. Referring back to procedure 1 of the experiment, which of the two juices is more useful as a general pH indicator and why? I think it is grape juice but I just don't know what...
This is to be done in excel (which I can do), but I am confused about...
This is to be done in excel (which I can do), but I am confused about which tail test to use and why to accept or reject H0- and the summary. According to research, holiday shoppers spent an average of $370 over a holiday weekend in 2008. The accompanying data show the amount spent by a random sample of holiday shoppers during the same weekend in 2009. Retailers were concerned that the economic downturn was affected holiday sales. Does this...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT