Another Java Project Problem

Rock Raiyu

Clock Up
OP
Member
Joined
Jul 14, 2007
Messages
5,066
Trophies
1
Age
32
Location
Walking the path of heaven
XP
2,349
Country
United States
For some reason, I can't compile my program I keep getthing the same error and for the life of me I can't figure out this problem. Here is my code, it has 3 parts to it which I've labeled.

http://pastebin.com/4ftMFk3K

Error is "Exception in thread "main" java.util.Input Mismatch Exception"

And the errors have to do with my scanner class. I can't post it here, as it apparently has long words..
 

caster62003

Well-Known Member
Member
Joined
Nov 22, 2008
Messages
111
Trophies
0
XP
85
Country
United States
Would it be possible to get the elev.txt file? I tossed your code into an Eclipse project, it compiles just fine, but when I run it, I get an exception that elev.txt is missing. So without that, I cannot debug very easily, if at all.

If you do not wish to share your elev.txt file, knowing what you said, and what I see on my end, I would say the issue lies more than likely in the elev.txt file. If I were you, I would setup some breakpoints in the ElevatorTest.java file in your do while loop, and check what is in the scanner for each time something is read from it. Also determine how much the scanner reads in before the exception occurs, does it get the Name? Weight? is it later on in the file it crashes? Are you missing a space in the file?

Aslo, a few minor cretiques, nothing that will solve the problem, but why do you have the main class throwing exceptions? What is possibly going to pick that up? Instead of this, use try a try catch block, also, your count variable is never used, at all, I would remove that. You are also missing comments, I would make sure to add those in. I don't know if this is just for personal gain, or if you will be graded on it, but I know if I would submit this to my professors, I know I would be docked for those issues.
 

Rock Raiyu

Clock Up
OP
Member
Joined
Jul 14, 2007
Messages
5,066
Trophies
1
Age
32
Location
Walking the path of heaven
XP
2,349
Country
United States
I posted a link for all the files for my project.

http://cse.spsu.edu/proth/1301/Projects/1301Proj5elevator.doc

That's the link to the project that she assigned.

And yeah I know its a rough draft cause I started working on it Sunday, knowing its due this Wednesday. So its missing some things and has some things that need to be removed. I'll keep your critique in mind when I finish it up.

http://www.mediafire.com/?25enojbi78vqbm4
 

caster62003

Well-Known Member
Member
Joined
Nov 22, 2008
Messages
111
Trophies
0
XP
85
Country
United States
I'll give you a hint, it doesn't crash in the do while loop, it crashes right after the scanner is made, and you ask for an integer to be stored into s, which then causes the whole thing to blow up, and causes the exception. I have no idea what all the variables mean, and what they are supposed to represent, which is why I recommend adding some comments, so if you want to, add some comments, and I'll take another whack at it, but at this point, there is your problem, hope it helps.

On a random side note, does your teacher not know the days of the week and their order? I never knew Tuesday came after Wednesday... :P
 

purplesludge

anyone have any ideas for this space
Member
Joined
Mar 2, 2009
Messages
1,047
Trophies
0
Age
34
Location
wv
Website
Visit site
XP
260
Country
United States
The problem with your scanner was the string before the number.
I fixed that and made some changes that I think would work better. The main one is using an arrays to store the values from the text file, then working with the arrays instead of the file.

I didn't change anything past line 25.

http://www.mediafire.com/?7lsplool9znnl84
 
Solution

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BigOnYa @ BigOnYa:
    Does it taste like... chicken?
    +1
  • S @ salazarcosplay:
    @BigOnYa I wanted to ask you about your experience with seeing south park. Most of the people a bit younger like my younger brother and cousins that are a few younger than me that saw kids found south park funny because of the curse words, kids at school, that seemed like liking the show on a very basic level.

    I could not quite have a in depth discussion of the show.

    How was it for you? As an adult. What did you find the most interesting part about it. Did you relate to the parents of the kids and their situations. Was it satires, the commentary on society. The references on celebrities' and pop culture.
    +1
  • BigOnYa @ BigOnYa:
    I remember seeing the very first episode back in the day, and have watched every episode since. I used to set my VCR to record them even, shows how long ago.
  • BigOnYa @ BigOnYa:
    I just like any comedies really, and cartoons have always been a favorite of mine. Family guy, American Dad, Futurama, Cleveland Show, Simpsons - I like them all.
    +1
  • BigOnYa @ BigOnYa:
    South Park is great cause they always touch on relavent issues going on today, and make something funny out of it.
    +3
  • S @ salazarcosplay:
    @BigOnYa were you always up to date on the current events and issues of the time or were there issues that you first found out thru south park
  • BigOnYa @ BigOnYa:
    Most of the time yea I knew, I watch and read the news regularly, but sometimes the Hollywood BS stuff, like concerning actors slip by me. I don't follow most Hollywood BS (example: the Kardasians)
    +2
  • S @ salazarcosplay:
    @BigOnYa there were relevant issues before south park was made, that's why i think a south park prequel/spinoff would be great. Randy and his friends in their child hood
    +1
  • BigOnYa @ BigOnYa:
    Yea, like them running in high school together, getting into stuff, and how they got hitched and had kids. And how the town of South Park was back then compared to now. That would be cool to see.
  • BakerMan @ BakerMan:
    yeah
  • The Real Jdbye @ The Real Jdbye:
    @salazarcosplay if they made a prequel, it would still be about current issues, cause it doesn't make sense to make it about stuff that happened 30 years ago that nobody cares about anymore
  • The Real Jdbye @ The Real Jdbye:
    it's too late
  • The Real Jdbye @ The Real Jdbye:
    the older south park episodes about particular issues usually age poorly since the topic is no longer relevant
  • The Real Jdbye @ The Real Jdbye:
    an exception is giant douche vs turd sandwich, that's always relevant :P
    +1
  • K3Nv2 @ K3Nv2:
    I was gone for like an hour and none of you thought to write or call pos
  • BigOnYa @ BigOnYa:
    We knew you were going to Sonic to get lunch.
  • K3Nv2 @ K3Nv2:
    Sonics fast I would've been home in 10 mins
  • BigOnYa @ BigOnYa:
    Meet and greet with AncientBoi then?
  • K3Nv2 @ K3Nv2:
    That would've gone slow he's old
    +1
  • ZeroT21 @ ZeroT21:
    sadly the person in question feels too young for his own good
  • K3Nv2 @ K3Nv2:
    We don't question people
  • ZeroT21 @ ZeroT21:
    me neither, i just bash them
  • K3Nv2 @ K3Nv2:
    We just question @AncientBoi
    K3Nv2 @ K3Nv2: We just question @AncientBoi