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
Lisa has a section of her document that she would like to include in the index. Which option should Lisa choose?
maksim [4K]

Answer:

In order to include a section of your text in the index, use the Mark Entry option.  

.) Select the text you want to reference

- this can be any form of text contained in the document

2.) Go to the References Tab

- In the references tab, find the Index Group

3.) Find the Mark Entry button in the Index Group

- in here, you will be able to fill out the required information in making your index, just follow the instruction accordingly, and you should be fine.

4.) close it when you're done.

8 0
2 years ago
Read 2 more answers
Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the num
Svetach [21]

Answer:

Logic for a program

Explanation:

//Here ind = index

//declare the number

number ind

number sum

number avg

number SIZE = 20

number num[SIZE] = {0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0}

getReady()

while ind < SIZE

getNumbers()

stop

getReady()

ind = 0

sum = 0

return

getNumbers()

cout<< “Enter a number for position ”, ind

input numbers[ind]

sum = sum + numbers[ind]

ind = ind + 1

return ;

finishUp()

avg = sum/SIZE

ind = 0

while ind < SIZE

output numbers[ind], avg – numbers[index]

ind = ind + 1

return

Modify the program in 2a

number index

number sum

number avg

number actualSize

number SIZE = 10

number number[SIZE] = 0

7 0
3 years ago
Why does temperature decrease with higher altitude?
Lelu [443]
It's B.

As you go up, the air thins out, meaning it is less dense. Since there are less molecules that can transfer heat, the temperature is lower.
4 0
3 years ago
What's a qat on a computer
suter [353]
The answer is ..........

The Microsoft Quick Access Toolbar (QAT<span>) is a toolbar menu that appears in Microsoft Excel, Microsoft Word, and other Office 2007 and above products in the top left corner of the window. As seen in the picture, the Quick Access Toolbar gives you quick access to commonly used features such as the Save feature.
</span>
hope it helps have a great one! :)
5 0
2 years ago
Read 2 more answers
Why is the yellow light blinking on the front of my computer
Yanka [14]

Answer:

that means it needs to get charged or it's on airplane mode not sure what else it could be

6 0
2 years ago
Other questions:
  • Consider that a large online company that provides a widely used search engine, social network, and/or news service is consideri
    12·1 answer
  • // This pseudocode is intended to display // employee net pay values. All employees have a standard // $45 deduction from their
    12·1 answer
  • To have the most impact when using email, you should structure your messages so that
    5·1 answer
  • How much health did a supply drop balloon originally have??
    7·2 answers
  • Which line is not a computer-generated forecast?Which line is not a computer-generated forecast?the black line representing 20th
    12·1 answer
  • 3. Before you get ready to go diving, you want to explore the area. You see a small snowpack across a small bridge, a short walk
    11·1 answer
  • Impanation stage contain ​
    10·1 answer
  • Which type of film would typically require the least amount of input from a screenwriter?
    10·1 answer
  • 1 pound is equivalent to how many grams?<br>A.463.59 grams<br>B.10 grams<br>C.59 grams<br>D.5 grams​
    8·2 answers
  • View One | View All
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!