Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Debugging Exercise 0 2 The code provided below contains syntax and / or logic errors. In each case, determine and fix the problem, remove all

Debugging Exercise 02
The code provided below contains syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
Code:
public class DebugCustomer
{
protected int idNumber;
protected String name;
protected double creditLimit;
public DebugCustomer(int id, name, double creditLimit)
{
idNumber = id;
name = name;
creditLimit = credit;
}
public void display()
{
System.out.println("Customer # + idNumber +
" Name: "+ name, "
Credit limit $"+ creditLimit);
}
}
public class DebugCustomerMakingPurchase extends DebugCustomer
{
private double amountOfPurchase;
private boolean overLimit;
public DebugCustomerMakingPurchase(int id,
String name, double credit, double purchAmount)
{
amountOfPurchase = purchAmount;
if(amountOfPurchase > creditLimit)
overLimit = true;
else
overLimit = true;
}
@Override
public void display()
{
this.display();
System.out.println("Purchase amount $"+ amountOfPurchase);
if(overLimit);
System.out.println("****Credit denied - customer over limit");
else
System.out.println("Purchase Okay");
}
}
// A customer's purchase is approved if the
// purchase does not exceed the credit limit
public class DebuggingExercise02
{
public static void main(String args[])
{
int id =12241;
String name = "Franklin";
double credit =1000.00;
double purchase =1325.77;
DebugCustomerMakingPurchase cust =
DebugCustomerMakingPurchase(id, name, credit, purchase);
cust.display();
}
}
Expected output:
Write your Java code in Eclipse IDE. Once you are happy with your resu

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

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago