Need help with Assignment. [Splitting Strings] [Full code provided]

Hi, I need help with an Assignment that requires me to continue(inheritance) on an existing assignment that I previously did.

When I compile them there are no syntax errors, but when I try to run the code it says "PatternSyntaxExeption: null(in java.util.regex.Pattern)". Do I need to use regex?

#This is the main code that uses all the methods.
[code]import java.util.Random;
import java.util.Scanner;

class pdaSIM{
public static void main(String args[]){
pdaCMD pda = new pdaCMD();
Random rand = new Random();
Scanner in = new Scanner(;

double credit = 0;
String battery_stat="[#][#][#][][]";
String emailData = "*This a test email.";

credit = 2+rand.nextInt(10);
//use power procedudure
pda.power = true;
//start of main code
//loops until power is false
while (pda.power == true){
//split emailData string
emailData = pda.splitEmail(emailData);
//displays layout
System.out.print(" ");

//displays menu;
//checks option chosen
switch (pda.menuCh) {
case 1: credit = pda.Call(credit); break;
case 2: credit = pda.topup(credit); break;
case 3: battery_stat = pda.recharge(battery_stat); break;
case 4: emailData = pda.readEmail(emailData); break;
case 5: emailData = pda.writeEmail(emailData); break;
case 6: //switch pda off
pda.power(); break;
default: System.out.print("Invalid choice.
"); break;


#I get the error in this class.
[code]import java.util.Scanner;
public class pdaCMD extends mobileCMD{
Scanner in = new Scanner(;

String temp[];

public String splitEmail(String emailData){
temp = emailData.split("*");
return emailData;

public String readEmail(String emailData){
for (int i=0; i 0){
credit = credit-0.5;
return credit;

public void showCredit(double credit){
System.out.print(credit+ "euros");

public double topup(double credit){
credit = credit+5;
return credit;

public void batteryStatus(String battery_stat){

public String recharge(String battery_stat){
if (battery_stat == "[#][#][#][#][#]"){
System.out.print("Battery charged.
Please unplug charger to save energy.

battery_stat = "[#][#][#][#][#]";
return battery_stat;

public void menu(){

1. Call
2. Topup
3. Recharge
4. Power ");
menuCh = in.nextInt();


Please help.
Anyone can use the code, if used a little indication that this was made by me (jean farrugia) would be much appreciated.(:


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion