So I’m getting some odd errors such as illegal start of type and variable’s that are not being used when I am clearly calling them. Now I’m using the latest version of netbeans and I’m no expert at Java but I believe that my netbeans may be corrupted or something not to sure.
As far as my logic goes with these if loops everything should be ok hence the reason I’m not going to go into too much detail about what the program is being used for.
Anyway here’s the code I will highlight the area’s with the errors.
Thanks in Advance Regards -Skeng-
import javax.swing.*;
import java.io.*;
public class Envelope extends Parcel {
protected char[] size = {'S','M','L'};
public Envelope(){
ImageIcon imageES = new ImageIcon ("..\\Images\\envelope-small.png");
ImageIcon imageEM = new ImageIcon ("..\\Images\\envelope-medium.png");
ImageIcon imageEL = new ImageIcon ("..\\Images\\envelope-large.png");
double ChargeS = 4.50;
double ChargeM = 8.50;
double ChargeL = 16.99;
double ChargeFinal = 0; **//Variable not being used**
if (size[0] == 'S') {
ChargeFinal = ChargeS;
} else if (size[1] == 'M') {
ChargeFinal = ChargeM;
} else if (size[2] == 'L')
ChargeFinal = ChargeL;
}
int zone = 0; //Zone will equal whatever the user selects for their parcel size
double zonecharge; //ZoneCharge will be the price depending on the zone
if (zone == 1) { **//Illegal Start of Type**
zonecharge = 0; **//Illegal Start of Type**
} else if (zone == 2) { **//Illegal Start of Type**
zonecharge = 1.5; **//Illegal Start of Type**
} else if (zone == 3) { **//Illegal Start of Type**
zonecharge = 2; **//Illegal Start of Type**
}
double EndPrice = ChargeFinal * zonecharge; **//Cannot find Symbol "ChargeFinal"**
System.out.println("Charge: £" + EndPrice); **//Illegal Start of Type**
@Override
public String toString() {
return "ID: " + idNum + "Zone: " + zone + "Charge: " + charge + "Size: " + size;
}
@Override
ImageIcon getImage() {
return image;
}
}
It’s because you’re missing a opening bracket after the first
else if