No! No! Got it all wrong.

I am so embarassed as I could have adressed this better. My intention was not trying to get answers to a homework assignment - i am not even in school. I just started trying to learn java on my own. A friend of mine who is a programming professor gave me a few problems to work on. I only wanted advice on how to approach the question not looking for answers, and I apologise if i did not make myself clear enough. I should have asked for help with my coding instead.
Sorry!

Here's a few lines to start you off (needs error handling, data validation and a whole bunch of other stuff, to complete your assignment)
import java.io.*;import java.util.*;import javax.swing.*;import javax.swing.event.*;
import java.awt.*;import java.awt.event.*;class PhoneAccount{
public static void main(String args[]){new PhoneGUI();}}
class PhoneGUI extends JFrame implements ActionListener{
ArrayList callsMade = new ArrayList();DefaultListModel listModel;JList jList;
JButton addBtn = new JButton("Add Record");JButton deleteBtn = new JButton("Del Record");
JTextField phoneNumberTf = new JTextField(20);JTextField typeTf = new JTextField(3);
JTextField costTf = new JTextField(8);  JLabel phoneNumberLbl = new JLabel("Phone Number:           ");
JLabel whereLbl = new JLabel("                    Type:      ");
JLabel costLbl = new JLabel(" Cost:");public PhoneGUI(){super("Phone Account");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Container frame = getContentPane();
frame.setLayout(new BorderLayout());listModel = new DefaultListModel();
jList = new JList(listModel);jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane listScrollPane = new JScrollPane(jList);addBtn.addActionListener(this);
deleteBtn.addActionListener(this);JPanel upper = new JPanel(new BorderLayout());
JPanel labels = new JPanel(new FlowLayout());JPanel texts = new JPanel(new FlowLayout());
JPanel btns = new JPanel(new FlowLayout());labels.add(phoneNumberLbl,FlowLayout.LEFT);
labels.add(whereLbl);labels.add(costLbl,FlowLayout.RIGHT);
upper.add(labels,BorderLayout.NORTH);texts.add(phoneNumberTf);texts.add(typeTf);
texts.add(costTf); upper.add(texts,BorderLayout.CENTER);btns.add(deleteBtn);
btns.add(addBtn);upper.add(btns,BorderLayout.SOUTH);JPanel lower = new JPanel();
lower.add(listScrollPane);frame.add(upper, BorderLayout.NORTH);
frame.add(lower, BorderLayout.SOUTH);pack();
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((dim.width - frame.getWidth())/2, (dim.height - frame.getHeight())/2);
setResizable(false);setVisible(true);try{loadPhoneLog();}catch(IOException e){}}
public void actionPerformed(ActionEvent ae){try{if(ae.getSource() == addBtn){
PhoneCall pc = new PhoneCall();pc.callNumber = phoneNumberTf.getText();
pc.callType = typeTf.getText().charAt(0);pc.callCost = Double.parseDouble(costTf.getText());
pc.printToFile();loadPhoneLog();phoneNumberTf.setText("");typeTf.setText("");
costTf.setText("");}else{if(jList.getSelectedIndex() >= 0){
callsMade.remove(jList.getSelectedIndex());savePhoneLog();loadPhoneLog();}
else JOptionPane.showMessageDialog(null,"Delete failure - no record selected");}}
catch(IOException e){}}private void loadPhoneLog() throws IOException{try{
BufferedReader br = new BufferedReader(new FileReader("PhoneLog.txt"));String line;
callsMade.clear();listModel.clear();while((line = br.readLine()) != null) callsMade.add(line);
br.close();sortCallsMade();for(int i = 0; i < callsMade.size(); i++){
listModel.addElement(callsMade.get(i));}jList.ensureIndexIsVisible(callsMade.size()-1);}
catch(FileNotFoundException fnfe){}}private void sortCallsMade(){String temp[] = new String[callsMade.size()];
for(int i = 0; i < temp.length; i++){temp[i] = (String)callsMade.get(i);}
Arrays.sort(temp);callsMade.clear();for(int i = 0; i < temp.length; i++){callsMade.add(temp);}}
private void savePhoneLog() throws IOException{FileWriter fw = new FileWriter("PhoneLog.txt");
for(int i = 0; i < callsMade.size(); i++) fw.write(callsMade.get(i).toString()+"\n");fw.close();}}
class PhoneCall{String callNumber;char callType;double callCost;
public void printToFile() throws IOException{FileWriter fw = new FileWriter("PhoneLog.txt",true);
fw.write(callNumber + " " + callType + " " + callCost + "\n");fw.close();}}

Similar Messages

  • HT1414 How do I totally erase an apple ID? I have somehow got it all wrong. I want to use the same email again.

    Help?

    OK, it seems like we are missing each other.  Here's the situation.  I have my Apple ID which is...[email protected](for example purposes).  I have 3 emails already attached to it...[email protected](The primary), [email protected](an alternate)  and [email protected](another alternate).  All 3 emails are currently attached and working with my Apple ID of [email protected]  Been like this for a year or 2 now, maybe even longer.  I do intend to continue using my own ID ([email protected]) as my own.
    I deleted the [email protected] because I am trying to set up an Apple ID for my daughter using [email protected] as her Apple ID.  It is her email and she's been using it for a couple years.  No reason to have her share my apple ID while using her email.
    The result is that every time I try and create a new ID using [email protected] as the Apple ID, I get the message that [email protected] is already associated with another Apple ID, even though I have deleted it from my ID of [email protected]

  • HT1212 My little children Majd enter the wrong passcode for more than 10 times, my iPhone automatically got reset all data was deleted. I managed to retrieve the contacts only but I'm unable to retrieve my SMS's and my photos???? Can you help me please ??

    My little children Majd entered the wrong passcode for more than 10 times, my iPhone automatically got reset all data was deleted. I managed to retrieve the contacts only but I'm unable to retrieve my SMS's and my photos???? Can you help me please ???

    Hi,
    Did you ever back up your phone on the computer?
    Did you use photo stream at all?
    May I suggest changing your passcode lock to a letters and numbers lock (if not all ready it will make your iphone more secure and a restore lock otion shouldent be needed). Then change your setting as well preventing restore after ten incorect passwords.
    kc

  • K9n2 bios reading my cpu temps all wrong

    K9n2 bios reading my cpu temps all wrong well actuly it not reading them at all my cpu AMD x2 5200 is said to be ideling at 26c but when i run a stress testor it stay at 26c so no change what so ever between load anf idle temps.
    my cou core temps are wrong any way and all wasy have been core 0 idle at -2c and core 1 -22c but they have goe up to core 1 26c and core 2 8c load so its obviously geting hotter but the motherboard isant repoting that it is :/ i have used manny difforent programs and all came back with 26-27c for the cpu no mater what i do i have bios 3.3.
    this never haped on my old ABIT kn9 sli it allways stated the corect cpu heat
    ohh and also speed fan carnt recogise the cpu it just says temp 1,2,3 for the motherboard where as befor it was cpu,core,chip and so on (that was with old board)
    any sugestions
    sorry for spelling im dyslexic

    well my cpu is back in my old motherboard with no problems at all no hard crashes and with the same ram timings the proper ram volts 2.1(msi board couldent handle 2.1v for ram) and the board only reports 26c no other temp used all temp programs and non of them changed when fully stresed only core temp showed any temp change but cart go buy that because my cores are so far off now on my old bard the temps go up and down like they should.
    i did clear the CMOS whith all unpluged
    all were at stock but ram voltage went to 1.8v so upped it to 2.1v (manual recomended) (wouldent start)
    at stock if i restarted pc for somthing like an update it wouldent post unless it was un pluged at pluged back in (at stock)
    and i have had no such problems with my old ASROCK board or my board im on now a ABIT kn9 570a sli
    ohh and the board came warped but the rear ports
    any way decided to go over to intel so got a EVGA board now and using a old p4 extream
    sorry to sound pissed of but 2 boards that were useless (each was from difforent Etailor)
    and windows was a fresh instal

  • Got my password wrong twice and my mini is disable. I connected to iTunes, but can't get it to work. Can some one guide my through?

    got my password wrong twice and my mini is disable. I connected to iTunes, but can't get it to work. Can some one guide my through?

    If it's showing the red disabled screen due to incorrect passcodes then you may need to put the iPad into recovery mode : http://support.apple.com/kb/ht1808 - you should then be able to reset the iPad via your computer's iTunes and restore/resync your content to it

  • My ipad 2 touchscreen doesn't work on most of the screen it got cracks all down the left side of my ipad and it has been working fine for a year after cracking but just woke up and touchscreen doesnt work i have tried to reboot it but still nothing

    my ipad 2 touchscreen doesn't work on most of the screen it got cracks all down the left side of my ipad and it has been working fine for a year after cracking but just woke up and touchscreen doesnt work i have tried to reboot it but still nothing

    It might be time to contact Apple for an out of warranty repair (actually replacement)
    See here: http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=ipad
    Replacement for any model iPad 2 is $249

  • TS3989 hi one guy stolen my iphone, and now i need my pictures which i have in my icloud i open my Apple id in icloud but i downlode just 20 pic how i got my all picturs in my pc?

    hi one guy stolen my iphone, and now i need my pictures which i have in my icloud i open my Apple id in icloud but i downlode just 20 pic how i got my all picturs in my pc?

    Update:  I reset my phone again and this time I restored it from my last iCloud backup.  That "sort of" worked.  (The missing info was on my phone temporarily, but it's still missing from iCloud.com and as the phone syncs with the cloud the missing contacts are disappearing.) 
    This is good news, but I'm losing progress.  How can I restore my iCloud settings to that last backup?

  • I have 6 ios devices. When we got icloud, all the information merged. How do i make everything go back to how it was before?

    I have 6 ios devices. When i got icloud, all the information merged together. How do i make it go to how i had it before.

    "Method Three
    Create a separate iTunes library for each device. Note:It is important that you make a new iTunes Library file. Do not justmake a copy of your existing iTunes Library file. If iTunes is open,quit it.
    This one may work. I searched and searched on the website for something like this, I guess I just didn't search correctly, lol. I will give this a try later. My daughter is not be back for a few weekends, therefore I will have to try the Method 3 when she comes back for the weekend again. "
    I forgot to mention that she has a PC at her house that she also syncs to. Would this cause a problem. I am already getting that pop up saying that the iPod is synced to another library (even though she is signed in with her Apple ID to iTunes) and gives the pop up to Cancel, Erase & Sync, or Transfer Purchases. My question arose because she clicked on "Erase & Sync" by mistake when she plugged the iPod to her PC the first time. When the iPod was purchased and setup, it was synced to my PC first. When she went home, she hooked it up to her PC and then she erased it by accident. I was able to restore all the missing stuff yesterday using my PC. However, even after doing that it still told me the next time I hooked it up last night that the iPod was currently synced with a different library. Hopefully, you can help me understand all this. She wants to sync her iPod and also backup her iPod at both places. Both PCs have been authorised. Thanks

  • Colors in Photoshop all wrong but OK in other apps. (For example "Whites appear yellow.")

    Q: The colors in Photoshop are all wrong. They have a neon look or are discolored with a blue, red, green or Yellow cast. I look at the same pictures in other applications and they look just fine. How do I fix this?
    A: Recalibrate your monitor using Adobe Gamma (OS9) or the Displays Control in System Preferences (OSX). Photoshop uses your monitor profile to display your images other apps don't. Be sure you start the recalibration using a fresh monitor profile (sRGB or the profile that came with your monitor for example). If you try to recalibrate using the old corrupt profile you will still have a corrupt monitor profile and your color will still be bad. Also, if you are using OS 9 make sure you are using ColorSync 3.0.4. The 3.0.4 patch is available on the Apple web site.
    See also support document 319456, "Colors Are Incorrect (For example White Appears Yellow)" at http://www.adobe.com/support/techdocs/319456.html. The document is for Windows, but it may be useful for Macintosh.
    Here is another link to monitor calibration http://www.gballard.net/psd/colorlooksbad.html

    Thanks. But it looks like in all my frustration, I wasn't  sure  my original call for help had posted, so must have  submitted the same question again.
    But I just had a new thought on the problem. While reviewing a story I received from another website,  I noticed that the photos attached to the article  looked  a lot like  what I described  in my  message. It made me wonder if I have a software problem at all . . . or if it's the screen on my Mac that needs recalibration!
    It only took 2 minutes to find a website that discussed it — with sample screens to help determine if that was what I'm dealing with. Since a screen supposedly showing a mix of numbered, grey boxes looked totally white to me and I could only see the white numbers on a screen that supposedly contained boxes in varying shades of black, I think I might be on the right track. Just not sure, since I had to reach the bottom of the page before spotting the pitch for a product that supposedly will recalibrate  for me. I'm not sure I want to tackle recalibration on my own, but may call the Mac Geniuses at our local mall  and see  if my hunch is right . . .and if so, what they would charge to do it for me.
    BTW, if it sounds like a calibration problem, do you think moving my computer  from one desk top another (just 5 feet away) could have caused it? I'm not sure, since it wasn't on my mind at the time, but I think that's roughly when I first started to notice discrepancies in color.

  • My cover albums o iTunes are just fine But when i sinc my iPhone the covers get All wrong and mixed up

    My cover albums o iTunes are just fine But when i sinc my iPhone the covers get All wrong and mixed up. What can i do?

    Perhaps you should ask over in the iPad community, you may get better answers there.
    It's actually my fault that psoon ended up here ... s/he intially posted over at Home Sharing, and I tried a relocate request to Apple TV rather than iPad.
    psoon, here's a link to the iPad community:
    Using iPad

  • I got it all figured out:)

    Hey,
    I finally got it all figured out. Burned an acceptable DVD-R (I use actual Apple certified media). When I took the time to configure Compressor (always the way to go by the way). I have it setup with my bitraye at about 6.8 with a max to 8.2.
    Image quality is great. I shot this film on my Panasonic DVX100 (original) in 24p Advanced mode. Letterbox 16:9. Plays well no my Mac mini and our consumer Sony DVD player. Look awesome!
    It did look grainy on my Superdrive on my iMac but so does my Smallville DVDs. For some reason it is playing DVDs at a lower quality. I will have to figure that one out but it should not prevent me from doing a nice screening at Galaxy Cinemas. Looks great and sounds great.
    So in short yes you can get good results just keep plugging away.
    Thanks for everything...
    Chris

    It appears you have accidentally subscribed to a community and were getting e-mails for all related posts. I have removed the subscriptions, so you should be getting no more e-mails. Thank you for bringing this to our attention. I'm sorry you recieved so many e-mails you did not want.

  • Anyone knows how to get the photos after IMG_9999 from iphone? :-(ps:... i got them all in my camera roll but when i connected to the computer there's nothing after IMG_9999..

    anyone knows how to get the photos after IMG_9999 from iphone? :-(ps:... i got them all in my camera roll but when i connected to the computer there's nothing after IMG_9999.. many thanks :-)

    They show in the camera roll, just not your computer?
    Have you checked every folder that is in the DCIM folder?

  • HUGE VIDEO PROBLEM!  The colors are all wrong!  Quicktime Gamma Bug!

    I'm on a Mac, and there is a huge problem with video.  When you view or playback videos, the color is all wrong!  It's desaturated and faded.  If you import your videos into premiere or playback through vlc, then everything looks correct. If you play them back or edit them in lightroom, the colors are all wrong. 
    Nice try Adobe, but you failed.         

    Ok, but we'll need more details.
    Your OS version, how you calibrate your monitor, whether you see the same playing through Quicktime standalone on your Mac, what camera the videos came from, whether they've been edited in other software, etc. 
    This is a beta so there will be bugs - that information could help narrow down and fix issues such as these.

  • Mac Book Pro just got it, all was well for 2 weeks now Finder window does not fill whole screen, there is an 1 1/2" space of black on the right side and the Finder window had a 1" section that flipped like a rolling tv now it is a white bar! Help!

    Mac Book Pro just got it, all was well for 2 weeks now Finder window does not fill whole screen, there is an 1 1/2" space of black on the right side and the Finder window had a 1" section that flipped like a rolling tv now it is a white bar! Help!

    Bad video card, call Apple, get a case number and return it.

  • IPad shared library view all wrong..help

    I have added several TV shows to my itunes library. Each show has the correct metadata (artwork, season, date, episode 3, etc).
    Don't worry this is all done legally via my "The Tube" software & digital TV tuner.
    Question & issue
    When I access my shared library (videos-->shared-->TV shows)
    The list is not at all organised like it is on the Apple TV 2.
    I understand they are two different products.
    The only way I can locate a show is via the artwork? No names unless I click the artwork.
    Some TV show are listed mutiple times.
    Some TV shows are not listed at all?
    Is there not a way to search for a TV show that is in my iTunes library via my ipad and view it on my ipad?
    This is very frustraging as some appear (mutiple times) and some don't.
    Everything have been properly encoded to play on all devices.

    no one?
    Maybe I'm explaining it all wrong....
    Below are some photos I took with my camera .
    The first photo is of my home movies season 2008
    This is of my shared library.
    fyi.... This is all legally obtained media via my cable provider & a neat app/hardware called tubestick
    I would really appreciate some help if anyone has any ideas....
    All videos have been properly encoded to play on my apple devices (iPad 1 & apple TV 2)

Maybe you are looking for

  • Jabber for Windows and Iphone

    We are running Jabber on cucm 9.1 WE use microsoft RDS and all works fine locally. users can sign in with their AD account and see their presence, use their deskphone and receive email. that works on both the windows and Iphone clients. When they are

  • What is mapLN and why is it eating all our space :)

    here's a DbPringLog from a few months ago: <pre> [xoopit@xda-004 ###]$ java -jar ~/###/je-3.3.74.jar DbPrintLog -s 0x00000000 -e 0x0000000a -S <DbPrintLog> Log statistics: type total provisional total min max avg entries count count bytes bytes bytes

  • PNP program error

    I am getting compilation error "DFIES has already been declared" when I use the program below (with logical DB PNP) REPORT  ZHR2. include DBPNPCOM. INITIALIZATION. rp-sel-ein-aus-init. start-of-selection. any idea what's wrong?  I am trying to write

  • GIS Reporting

    I have a specific requiremnent to create GIS reports. I have an object called Area which is a Static Geo Characteristic. I have loaded the .shp, .dbf and .shx files for this area. The area map can be viewed in Bex. I also have an address infoobject w

  • Webdynpro FPM Table Control Toolbar Buttons

    Dear Experts, In Webdynpro FPM Configuration, Table control tool bar to be enhanced with custom buttons and it should call the custom web dynpro applications. After adding the buttons, where we have to configure the FPM Event ID's and corresponding a