Need help please (student programmer).
Hi all. I was wondering if anyone can give me a solution to my problem.
I will 1st print my source code and then refer you to my problem...
Assignment 2: Chapter 4
Programmer: Yucca Nel
Date: 28 November 2007
Filename: MyType.java
Purpose : This Program helps beginner java programmers better understand java data types.
import java.io.*;
import javax.swing.JOptionPane;
public class MyTypeSwing
public static void main(String[] args) throws IOException
// Declare variables
String strChoice, strTryString, strTryInt, strTryDouble;
int choice, tryInt;
double tryDouble;
boolean done = false;
//loop
while(!done)
try
strChoice = JOptionPane.showInputDialog(null,"Whats My Type?\n\n1)String\n2)integer\n3)double\n4)Quit the program");
choice = Integer.parseInt(strChoice);
switch(choice)
case 1:
JOptionPane.showMessageDialog(null,"Correct! Any input can be saved as a string");
break;
case 2:
JOptionPane.showMessageDialog(null,"Correct");
break;
case 3:
JOptionPane.showMessageDialog(null,"Correct");
break;
case 4:
done = true;
JOptionPane.showMessageDialog(null,"Program will now close");
break;
default:
throw new NumberFormatException();
catch(NumberFormatException e)
JOptionPane.showMessageDialog(null,"You must enter a 1, 2, 3, or 4 ","Error",JOptionPane.INFORMATION_MESSAGE);
now for the problem. The exercise I am doing requests me to include the following:
1) I need to parse the value to tryInt in case 2:
2) Likewise in case 3: I need to parse the value to tryDouble
the problem I have is that as you will see I have declared all variables and I am not allowed to declare them again within the switch statement. According to the exercise nothing more needs to be done to the application, meaning that there were no instructions on anything else needed to be done. According to the instructions I am 100% sure that I need to do 1) and 2) within the switch(choice) I am so stuck and I would appreciate help.
No the instruction is as follows....
1. Type a class header and an opening brace to begin class.
2. Type public static void main(String[] args) and an opening brace to begin the main() method header
3. Declare the following variables using the code:
String strChoice, strTryString, strTryInt, strTryDouble;
int choice, tryInt;
double tryDouble;
boolean done = false;
4. Begin a while(!done) loop to repeat as long as the user does not click the cancel button.
5. Inside a try statement, enter code to display an input box as shown in figure (THIS IS CORRECT)
6.Type choice = Integer.parseInt(strChoice); on the next line to parse the value for the choice entered by the user.
7.Create a switch statement to test for each of the three choices. Type switch(choice) as the header and then press the ENTER key. Type an opening brace.
8.Enter a cas statement for each of the 3 choices using pages (blah blah) as a guide (did that), for coding the switch, case and break statements.
-case1: If the user enters 1, Display a message to inform users that they are correct, as any data can be saved as a string.
-case2: If the user enters 2, ***************where i have a problem*********************parse the value into tryInt.Display message.
etc. etc. It states that I need to do the parse within that specific point. Please help.
Similar Messages
-
My Ipad is disabled by wrong password and I have tried to reset and restore a few times with no success. Now I-tunes won't even recognize the I-pad in recovery mode. I need help please.
If the iPad was running iOS 7, iCloud: Find My iPhone Activation Lock in iOS 7
http://support.apple.com/kb/HT5818
How can I unlock my iPad if I forgot the passcode?
http://www.everymac.com/systems/apple/ipad/ipad-troubleshooting-repair-faq/ipad- how-to-unlock-open-forgot-code-passcode-password-login.html
iOS: Device disabled after entering wrong passcode
http://support.apple.com/kb/ht1212
How can I unlock my iPad if I forgot the passcode?
http://tinyurl.com/7ndy8tb
How to Reset a Forgotten Password for an iOS Device
http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
Using iPhone/iPad Recovery Mode
http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
Saw this solution on another post about an iPad in a school environment. Might work on your iPad so you won't lose everything.
~~~~~~~~~~~~~
‘iPad is disabled’ fix without resetting using iTunes
Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
2. Open iTunes with the iPad disconnected.
3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
5. Click ‘Setup as new iPad’ and then click restore.
6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
8. The first stage in the restore process unlocks the iPad, you are basically just cancelling out the restore process as soon as it reactivates the iPad.
If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
~~~~~~~~~~~~~
Try it and good luck. You have nothing more to lose if it doesn't work for you.
Cheers, Tom -
How can I add a new Template to My Templates in Pages? I've read most of the discussions on the subject but it doesn't work for me. By the time I reach the Templates folder, I only see templates for Numbers and not for Pages. Need help, please. Thanks
Si vous avez utilisé la commande Save As Template depuis Pages, il y a forcément un dossier
iWork > Pages
contenant Templates > My Templates
comme il y a un dossier
iWork > Numbers
contenant Templates > My Templates
Depuis le Finder, tapez cmd + f
puis configurez la recherche comme sur cette recopie d'écran.
puis lancez la recherche.
Ainsi, vous allez trouver vos modèles personnalisés dans leur dossier.
Chez moi, il y en a une kyrielle en dehors des dossiers standards parce que je renomme wxcvb.template quasiment tous mes documents Pages et wxcvb.nmbtemplate à peu près tous mes documents Numbers.
Ainsi, quand je travaille sur un document, je ne suis pas ralenti par Autosave.
Désolé mais je ne répondrai plus avant demain.
Pour moi il est temps de dormir.
Yvan KOENIG (VALLAURIS, France) mercredi 23 janvier 2011 22:39:28
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community -
I am trying like **** to download itunes 10.6.3 (64 bit - Windows 7) and I keep getting "the installer was interrupted before the requested operations for iTunes could be completed. Your systems has not been modified." I NEED HELP, PLEASE!
I got it figured out myself... yaaaaay for me!
-
After my iphone4S update to 7.0.6, it have a problem that keep searching network then no service show on display. Can't call. I have try check sim card, reset network settings, and restore my iphone. Still not working at all. Need help please.Urgent.TQ
Izit software or hardware? Confuse:(
Only can use wifi now.
Any way thanks guys for ur suggestion:) amishcake and simes -
Bought a new macbook and want to manually manage music onto my iphone 4s (as it is already full of music from old windows laptop) but when i click 'manually manage' and then 'apply' i get the message saying it will erase everything already on there. Need help please!
Before you sync your iPhone make sure that all the music that was synced to your phonereviously has been copied to your iTunes on the new MacBook Pro. Then when you connect your phone you will be able to either sync all music or select only those playlists that you want on the phone.
-
Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.
Contact iTunes
Contact iTunes -
Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. When I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.
Hello Vaidas Vaidas,
It sounds like you are noticing someone else is accessing your Clash of Clans data by playing the game and you have tried to reset your Apple ID password. If you are following the steps outlined in this article:
Apple ID: Changing your password
http://support.apple.com/kb/ht5624
What is preventing you from changing your password? Any error messages or prompts?
Thank you for using Apple Support Communities.
All the best,
Sterling -
i dont know how i got my photos to my ipod touch from my pc and now i wanna delete them but couldn't. so need help. please let me know.
To turn off auto sync - launch iTunes and go to Edit>Preferences>Devices - check the box at the bottom that says - Prevent iPod, iPhones and iPads from syncing automatically. Click OK and then quit iTunes.
Connect your iDevice to your PC.
Launch iTunes,
Click on the device name on the left side of the iTunes Window.
Click on the Photos Tab in the iTunes window on the right.
Untick all of the photos or albums that you want to remove.
Click on Apply in the lower right corner of iTunes
If you untick or uncheck the Sync Photos heading and then click Apply it will remove all of the photos from the device when it syncs. In this screenshot - I have only certain albums and events selected to sync. -
My iPhone 6 can't find my macbook pro on the airdrop list, although everything is in place, bluetooth, wi fi gets, need help please ?
Dear Niel, thank you but my mac is (MacBook Pro (Retina, 15-inch, Early 2013).
and i can send from it to my iPhone , but not vice versa -
After many months of non-use, when I tried to open Photoshop CS4 Extended, I got an error message 148.3. "Licensing for this product has stopped working." I need help, please.
Error "Licensing has stopped working" | Windows
Error "Licensing has stopped working" | Mac OS
Mylenium -
I need help please I keep getting error messega 21 when i try uploading my iPhone 4 s!!!!!!!!! omg some one please tell me if and how to fix this please. thank you!!!
Hopefully this link will help you: http://support.apple.com/kb/HT2109
-
Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.
Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.
-
After updating my Iphone 5 my lock button isnt working well .... Need help please ..
First, read here:
https://ssl.apple.com/support/iphone5-sleepwakebutton/
See if your phone is affected. -
hi
i need help please . when i want to buy app from store ask me the security question
but i forgot the answer
so i need to the link to rest answer of security questionThe Best Alternatives for Security Questions and Rescue Mail
a. Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
b. Call Apple Support in your country: Customer Service: Contact Apple support.
c. Rescue email address and how to reset Apple ID security questions.
Maybe you are looking for
-
Mail crashing on failure to authenticate cyrus user
Mail crashed, and now will not warn re-start (a cold start of the server works) with error: no entry in /etc/passwd for user _cyrus can't change to the cyrus user: No such file or directory The IMAP logs also show, for ALL users, even though all user
-
LCD Shows Only Green or Pink or Orange, etc, Screen After 10.5.8 Upgrade
My Lacie LCD monitor came up solid green after restarting following the update to 10.5.8. Every time I turn the monitor off then on, it just shows a different solid color. Right now I'm plugged in to an old CRT and it works fine. Was it the upgrade t
-
How can I download a list of import condition types used in POs (STP)
Hi Experts, Do any of you know how can I download such a list from SAP? I'm enclosing images of what I need, it'd be great if I could have for instance an excel report of what condition types I have per material for all purchase orders in a determina
-
y iPad2 is frozen, I am trying to download the upgrade software but fails after a while, how can I solve the issue. I have not upgraded the iPad 2 since I bought it.
-
ComponentWorks work abnormally with C++ Builder 5.0
I am an user of ComponentWorks(full version). I formerly used ComponentWorks with C++ Builder 4.0 professional and they worked together ok. Recently, I¡¯ ve updated C++ Builder 4.0 to C++ Builder 5.0 enterprise suite, then ComponentWorks worked abnor