1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dima020 [189]
3 years ago
15

Please debug the below code in Java please.

Computers and Technology
1 answer:
lisabon 2012 [21]3 years ago
5 0

Answer:

Check the explanation

Explanation:

//Bugs are highlighted in bold text

class Invoice

Declarations

private num invoiceNumber

private string customer

private num balanceDue

private num tax

public void setInvoiceNUMBER(num number)

Declarations

num LOW_NUM = 1000

num HIGH_NUM = 9999

if number > HIGH_NUM then

invoiceNumber = 0

else

if number < LOW_NUM then

invoiceNumber = 0

else

invoiceNumber = num

endif

return

public void setCustomer(string cust)

customer = cust

return

public void setBalanceDue(num balance)

//Bug balanceDue is Invoice class varible

//but it is assigned to balance .it gives error

balance = balanceDue

setTax()

return

private void setTax()

Declarations

//Bug TAX_RATE is declared as string

//but assigned a double value

string TAX_RATE = 0.07

tax = tax * TAX_RATE

return

public void displayInvoice()

output "Invoice #", invoiceNumber

output "Customer: ", customer

output "Due: ", balanceDue

output "Tax: ", taxDue

//Bug

//Invoice class has no variable called balance .it should be balanceDue

output "Total ", balance + taxDue

return

endClass

start

Declarations

Invoice inv1

Invoice inv2

Invoice inv3

//Warning

//it gives warning object taken but not initilaized

Invoice inv4

inv1.setInvoiceNumber(1244)

inv1.setCustomer("Brown")

inv1.setBalanceDue(1000.00)

inv1.displayInvoice()

inv2.setInvoiceNumber(77777)

inv2.setCustomer("Jenkins")

inv2.setBalanceDue(2000.00)

inv2.displayInvoice()

inv3.setInvoiceNumber(888)

inv3.setCustomer("Russell")

inv3.setBalanceDue(3000.00)

//Bug

//setTax method of Invioce doesnot take any arguments

inv3.setTax(210.00)

inv3.displayInvoice()

stop

//Here is the complete program in c++

//Run the program using Microsoft visual studio 2010 vc++

#include<iostream>

#include<iomanip>

#include<string>

using namespace std;

class Invoice

{

//class varibales

private:

           int invoiceNumber;

           string customer;

           double balanceDue;

           double tax;

//class methods

public:

           void setCustomer(string cus);

           void displayInvoice();

           void setBalanceDue(double balance);

           void setInvoiceNUMBER(int number);

           void setTax();

};

void Invoice::displayInvoice()

{

cout<< setw(10)<<"Invoice #"<<setw(5)<<invoiceNumber<<endl;

cout<<setw(10)<<"Customer: "<<setw(5)<<customer<<endl;

cout<<setw(10)<<"Due: "<<setw(5)<<balanceDue<<endl;

cout<<setw(10)<<"Tax: "<<setw(5)<<tax<<endl;

//Bug

//Invoice class has no variable called balance .it should be balanceDue

cout<< "Total "<< balanceDue + tax<<endl;

}

void Invoice::setCustomer(string cust)

{

customer = cust;

}

void Invoice::setInvoiceNUMBER(int number)

{

const int LOW_NUM = 1000;

const int HIGH_NUM = 9999;

if( number > HIGH_NUM )

invoiceNumber = 0;

else

if (number < LOW_NUM )

       invoiceNumber = 0;

else

   invoiceNumber = number;

}

void Invoice::setBalanceDue(double balance)

{

balanceDue = balance;

}

void Invoice::setTax()

{

double TAX_RATE = 0.07;

tax = balanceDue * TAX_RATE;

}

int main()

{

Invoice inv1;

Invoice inv2;

Invoice inv3;

inv1.setInvoiceNUMBER(1244);

inv1.setCustomer("Brown");

inv1.setBalanceDue(1000.00);

inv1.setTax();

inv1.displayInvoice();

inv2.setInvoiceNUMBER(77777);

inv2.setCustomer("Jenkins");

inv2.setBalanceDue(2000.00);

inv2.setTax();

inv2.displayInvoice();

inv3.setInvoiceNUMBER(888);

inv3.setCustomer("Russell");

inv3.setBalanceDue(3000.00);

inv3.setTax();

inv3.displayInvoice();

system("pause");

return 0;

}

Kindly check the output image below.

You might be interested in
Select the correct answer. Which sign or symbol will you use to lock cells for absolute cell reference?
worty [1.4K]

Answer:

A. ampersand

Explanation:

7 0
2 years ago
Read 2 more answers
A rang check that could be use to validate... Date and time
lisov135 [29]

A range check is often used when a person works with data consisting of numbers, dates and times, or currency, ensuring that a number is within a specific range.

Explanation:

  • Range checks allow a person to set suitable boundaries.
  • An example of a range check is checking to see if the value of a 16-bit integer is within the capacity of a 16-bit integer. When a range check is performed, upper and lower boundaries are specified.
  • Range check is a validation check which can be applied to numeric fields. This is done to ensure that only numbers within a certain domain can be entered into a field. Remember that this does not necessarily mean that the data entered will be correct. But it will certainly lie within reasonable limits.
  • A method of validation which checks that data falls between an upper and lower acceptable value.
  • This validation check which can be applied to numeric fields. This is done to ensure that only numbers within a certain domain can be entered into a field. Remember that this does not necessarily mean that the data entered will be correct. But it will certainly lie within reasonable limits.
5 0
3 years ago
Consider the system of simultaneous equations:
FromTheMoon [43]

Answer:

System of linear equations is solved below and explained in detail.

Explanation:

Part a:

M = [1  3  5  2; 2  -4  7  -3; 0  -4  -7  3; 5  -3  2  1];

c =  [7;  -3;  -1;  0];

Part b:

The statement used for the solution of system of linear equation will be:

X = linsolve(M,c)

where X will give the values of x1, x2, x3, x4 respectively.

Part c:

The system is solved in matlab using above equation and the results are attached in a file.

The values for X are:

x1 = -2/7

x2 = 3/7

x3 = 4/7

x4 = 11/7

4 0
3 years ago
This function whose primary purpose is to display information to the user can only display one value at a time.
Leya [2.2K]

Answer:

False

Explanation:

The functions that was made for display content can get  arguments of different type e.g. (Int, string, Array, Objects) and if you want to display n values you only have to check the syntax of your programming language to separate one of each other

# Python example

a = "Hello-"

b = "World"

c = 10

print(a,b,c)

#Out: Hello-World10

I hope it's help you.

4 0
3 years ago
_______ refers to the use of gps or rfid technology to create virtual boundaries that enable software to trigger a response when
ludmilkaskok [199]

Geofencing Marketing refers to the use of gps or rfid technology to create virtual boundaries that enable software to trigger a response when a mobile device enters or leaves a particular area.

<h3>What is Geofencing Marketing?</h3>
  • Geofencing marketing is an illustration of a real-time location-based trade tactic that utilizes geolocation data to mark users within a specified geographic region and delivers a range based on where they are or in what areas they have previously visited.
  • Geofencing marketing concerns setting up virtual borders around a point or area that tracks whenever someone with a portable device crosses them.

To learn more about Geofencing Marketing, refer:

brainly.com/question/9795929

#SPJ4

4 0
1 year ago
Other questions:
  • How will a packet tracer environment be affected if a heater is added to a container named branch office and turned on?
    5·1 answer
  • What's another name for the Super High shot, if you shot it on the ground using a tripod?
    14·1 answer
  • Select the correct answer.
    6·1 answer
  • The main purpose of a service panel in a house is to
    11·1 answer
  • Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. T
    7·1 answer
  • Compiler is an example of​
    5·1 answer
  • Join each of the follwing sentences using unless
    14·2 answers
  • Why do my airpods keep disconnecting from my laptop
    8·2 answers
  • A(n) _____ is a computerized system by which subscribers are able to communicate to all other subscribers by sending a transmiss
    5·1 answer
  • Instructions: Write a program that calculates the amount of ingredients needed for various flavors of cheesecake.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!