Friday, July 31, 2009

JAVA Programming Help!!?

Im trying to import a text file using the scanner class into an array. I have the text file that is in an array format (ie first row 4 5 8 3 second row 6 2 3 5, etc.) and I am trying to assign the values by using the scanner.





This is what I have so far to work with:











public static void main (String[] args){


int [][] work = new int [8][8];


int [] Employee = new int[8];


for (int j =0; j%26lt;work[8].length; j++){


for (int i =0; j%26lt;work.length; i++){


Scanner inFile = new Scanner (System.in);


System.out.print("Enter an integer:");


work[j][i]=inFile.nextInt();


Employee[j]+=work[j][i];


}


}











The text file is 7x7 as is the array type seen above. How do I get the Scanner to read from the text file and assign the variables?





Thanks in advance. By the way the file name of the text file is "C:\work.text" thanks....

JAVA Programming Help!!?
The code posted, give or take a bit, should work.





Just compile it:


javac class.java





Then run it and pipe in the file:


java class %26lt; C:\work.txt
Reply:I'm a C++ guy, but I notice that your array and loop is 8x8 but you said the data is 7x7. Is work[8].length a valid reference? I think only work[0..7] are valid. I don't think you want to create a new Scanner for every value, but as I said, I'm a C++ guy.


How might you .............. Java?

I am redoing a C++ program in java, Garage.java, which I haven't used in a while. It compiles, runs, but nothing pops up as it should, there is a JOptionPane in the 3rd function. My skeleton is as follows:





[imports]





public class Garage


{ /*Globals*/


/* What is the following for, I used to run the


functions in the main, but when i do that it says


non-static in static context or something like that?*/


public void Garage()


{


fillA();


print();


}





public void fillA()


{


/*Function 1 calls function 2*/


}


public void parkC()


{


/*JOPane*/


}


public static void main (String args[])


{


Garage application = new Garage(); //What is this?


System.exit(0);


}

How might you .............. Java?
Your class is 'Garage'.


'new Garage()' is the constructor call for a 'Garage'.


Your instance of 'Garage' is called 'application' (not a good name).


'public void Garage()' is NOT a constructor method (and not a good name for a method in 'Garage').


sooooooooooo


You need to call 'application.Garage()' after the constructor in 'main'.


orrrrrrrrrrrrrrr


You could change 'public void Garage()' to 'public Garage()' to make it a constructor method (which you already have a call to).
Reply:the first problem is "System.Exit(0);" closes the program.... and the constructor for garage should be "Public Garage()" not "public void Garage()"

flower garden

Physics homework help please!?

I really don't want to hear anyone preach at me and tell me I should have done this myself.I was thrown into this class (even though I don't need it) and I can't get out.I am learning disabled and need some help.So please save your little speeches for someone else.





10 A 98.2 N grocery cart is pushed 11.8 m along


an aisle by a shopper who exerts a constant


horizontal force of 33.6 N.


The acceleration of gravity is 9:81 m=s2 :


If all frictional forces are neglected and the


cart starts from rest, what is the grocery cart's


final speed? Answer in units of m=s.





13 A 1.45 kg ball is attached to a ceiling by a


0.767 m long string. The height of the room


is 3.82 m.


The acceleration of gravity is 9:81 m=s2 :


What is the gravitational potential energy


associated with the ball relative to


a) the ceiling? Answer in units of J.





14 b) the door? Answer in units of J.





015 c) a point at the same elevation as the ball?


Answer in units of J.

Physics homework help please!?
(10) Since they give the weight of the cart instead of the mass, divide the weight by the acceleration of gravity to get the mass. Then use Newton's Second Law:





F = ma





33.6 N = ( 98.2 N / 9.8 m/s² ) a





2 a d = v²





Plug in 11.9 m for distance and the acceleration you just got and solve for the final velocity v.





(13, 14, 15) Gravitational potential energy is mgh. Relative to the ceiling, the height is -.767 m. Relative to the floor, it's ( 3.82 - .767 ) m. Relative to the same elevation as the ball is zero.





Solve for the acceleration a. Then


What's wrong with the following program (if any)?

a.Nothing is wrong with the program


b.Adding similar key values to a Hashmap results in an exception


c.The constructor method PMs() is wrong


d.The size() method is wrong





import java.util.*;


public class PMs {


private Map m = new HashMap();


public void PMs() {


m.put("Nehru", "Jawaharlal");


m.put("Nanda", "Gulzarilal");


m.put("Shastri", "Lal Bahadur");


m.put("Gandhi", "Indira");


m.put("Desai", "Morarji");


m.put("Singh", "Charan");


m.put("Gandhi", "Rajiv");


m.put("Singh", "Vishwanath Pratap");


m.put("Shekhar", "Chandra");


m.put("Rao", "Narasimha");


m.put("Vajpayee", "Atal Behari");


m.put("Gowda", "Deve");


m.put("Gujaral", "Inder Kumar");


m.put("Singh", "Manmohan");


}


public int size() { return m.size(); }


public static void main(String args[]) {


PMs primeministers = new PMs();


System.out.println("Prime ministers with different last name = " + primeministers.size());


}


}

What's wrong with the following program (if any)?
Hi program will compile


o/p


Prime ministers with different last name = 0





i find your logic wrong at





public int size() { return m.size(); }


public static void main(String args[]) {


PMs primeministers = new PMs();


System.out.println("Prime ministers with different last name = " + primeministers.size());


}





instead of doing this you can use something like





import java.util.*;


import java.util.HashMap;


public class PMs {





public static void main(String args[]) {


Map m = new HashMap();








m.put("Nehru", "Jawaharlal");


m.put("Nanda", "Gulzarilal");


m.put("Shastri", "Lal Bahadur");


m.put("Gandhi", "Indira");


m.put("Desai", "Morarji");


m.put("Singh", "Charan");


m.put("Gandhi", "Rajiv");


m.put("Singh", "Vishwanath Pratap");


m.put("Shekhar", "Chandra");


m.put("Rao", "Narasimha");


m.put("Vajpayee", "Atal Behari");


m.put("Gowda", "Deve");


m.put("Gujaral", "Inder Kumar");


m.put("Singh", "Manmohan");





Iterator it = m.keySet().iterator();


while (it.hasNext()) {


System.out.println("Prime ministers with different last name =" + it.next());


}


}


}





hope this helps


Cheers:)
Reply:why dont you learn java and answer it yourself
Reply:all this greek to me


Triangles. math help please?

i need help really bad with this math homework. can someone show me how. my online class doesnt show me how.





A boy is flying a kite and is standing 30 feet from a point directly under the kite. If the string to the kite is 50 feet long, find the angle of the elevation of the kite.


A)126.87° B) 36.87° C)53.13° D)112.6°





The approach pattern to an airport requires pilots to set an 11° angle of descent toward a runway. If a plane is flying at an altitude of 9,500 m, at what distance (measured along the ground) from the airport must the pilot descend?


A)48,873 m B) 9,677.81 m C)49,788 m D) 40, 645 m

Triangles. math help please?
1) hypotenuse = string of kite = 50 ft


ajacent = distance from base of kite = 30 ft





cos x = adj/hypt





x = cos-1 (adj/hypt)


x = 53.13 or c)





2) angle = 11 degrees


altitude = opposite = 9500


runway = adjacent


use tan x = opp/adj


adj = opp/tan 11


adj = 48873 or a)





hope that helps
Reply:1)





Draw the right triangle ABC, where %26lt;B = 90 degrees.





let A represents point of kite.





C represents the boys standing position and BC = 30 ft.





AC = length of kite = 50 ft





angle of elevation = %26lt;ACB





cos(ACB) = BC/AC = 30/50





cos(ACB) = 0.6





angle of elevation,%26lt;ACB = cos^-1(0.6) = 53.13 degrees





2)





In right triangle ABC,





A represents position of plane.





BC = required distance on the ground.





AB = altitude = 9500 m





angle of descent = %26lt;BAC = 11 degrees





cot(BAC) = BC/AB





BC = AB*cot(BAC) = AB/tan(BAC)





BC = 9500/tan(11) = 9500/0.19438 = 48,873 m
Reply:————————————————


Problem A


————————————————


Sketch a triangle and label it to make sense of the problem:





%26lt;|%26gt;


|.\


|...\


|.....\ ← 50ft of string


|.......\ O


|.........\|


|_____/\


....↑30 feet from from the point directly below





angle of elevation is from the ground up:





....\


...θ.\


___(_\





So this tells us:


Angle: from ground, unknown


String: 50 ft hypotenuse


Distance from kite: 30 ft on ground, adjacent to desired angle





to remember what trig function to use, remember:


soh cah toa


(said like "so cuh toe-uh")





meaning:


s = o/h


c = a/h


t = o/a





for


Sin(θ) = Opposite/Hypotenuse


Cos(θ) = Adjacent/Hypotenuse


Tan(θ) = Opposite/Adjacent





In this case, we have the side near the angle (adjacent) and the hypotenuse (the long, angled side), so we use:


cos(θ) = adjacent/hypotenuse





cos(θ) = (distance from kite)/(string length)


cos(θ) = 30/50


cos(θ) = 3/5





The opposite of cos is arccos(x), also labeled cos^-1(x)


arccos(3/5) ≈ 53.1301°





----





Answer:


C) 53.13°





————————————————


Problem B


————————————————


Again, sketch a drawing:





%26gt;=|)%26gt; ---------


..\ ) θ ← angle of descent is from a horizontal line down,


....\ .....|..... not from the ground up like angle of elevation


.....\.....|


.......\...| ← 9500 m above ground


..........\|








We have the side away from the angle this time (opposite)and want the side along ground, which isn't the hypotenuse but the other leg of the triangle. We can set up the triangle in different ways here:


______


|\θ......|


|..\......| ← we can make this triangle from the sky down


|....\....|


|.....\...|


|___θ\ |


↑or one from the ground up





The two places where theta (θ) is at have the same angle, and the top sides both have the same measurement as do the two sides. Depenending on how we set this problem up, we will have to move at least one of these things to an identical spot to set the problem up right. In this case, we want the distance along the ground, but that is the same as the horizontal distance at the of the triangle that was originally drawn for this problem.





Since it gives the angle at the top down and the height (opposite side to that angle) and asks for horizontal distance (adjacent side to that angle), we want opposite and adjacent:





soh cah toa





tangent = o/a is what we want





tan(θ) = opposite/adjacent


tan(angle of descent) = (height above ground)/a


tan(11°) = (9500)/a





a·tan(11°) = [ (9500)/a ]·a


a·tan(11°) = (9500)


a·tan(11°)/tan(11°) = (9500)/tan(11°)


a = (9500)/tan(11°)





a ≈ 48873.263





----





Answer:


A) 48,873 m





----





Hope this helps!


Thursday, July 30, 2009

What do you think about this funny ideas?

Confucius Says.....


"Man who run in front of car get tired"


"Man who run behind car get exhausted"


"Two wrongs not make a right - Three lefts do"


"Man who eat many prunes get good run for money."


"War doesn't determine who's right. War determines who's left."


"Man who tell one too many light bulb jokes soon burn out!"


"Man who sit on tack get point!"


"Man who stand on toilet is high on pot!"


"Man who lives in glass house should change in basement"


"If you want pretty nurse, you got to be patient."








Top 10 Words That Don't Exist... But Should...


1. AQUADEXTROUS (ak wa deks' trus) adj. Possessing the ability to turn the bathtub faucet on and off with your toes.


2. CARPERPETUATION (kar' pur pet u a shun) n. The act, when vacuuming,or running over a string or a piece of lint at least a dozen times, reaching over and picking it up, examining it, then putting it back down to give the vacuum one more chance.


3. DISCONFECT (dis kon fekt') v. To sterilize the piece of candy you dropped on the floor by blowing on it, assuming this will somehow remove all the germs.


4. ELBONICS (el bon' iks) n. The actions of two people maneuvering for one armrest in a movie theater.


5. FRUST (frust) n. The small line of debris that refuses to be swept onto the dust pan and keeps backing a person across the room until he finally decides to give up and sweep it under the rug.


6. LACTOMANGULATION (lak' to man gyu lay' shun) n. Manhandling the "open here" spout on a milk container so badly that one has to resort to the 'illegal' side.


7. PEPPIER (pehp ee ay') n. The waiter at a fancy restaurant whose sole purpose seems to be walking around asking diners if they want ground pepper.


8. PHONESIA (fo nee' zhuh) n. The affliction of dialing a phone number and forgetting whom you were calling just as they answer.


9. PUPKUS (pup' kus) n. The moist residue left on a window after a dog presses its nose to it.


10. TELECRASTINATION (tel e kras tin ay' shun) n. The act of always letting the phone ring at least twice before you pick it up, even when you're only six inches away.








Giving 100%


Ever wonder about those people who say they are giving more than 100%?


We have all been to those meetings where someone wants over 100%.


How about achieving 103%? Here's a little math that might prove helpful.


What makes life 100%?


If


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z is represented


as:


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26.


Then,


H A R D W O R K


8 1 18 4 23 15 18 11 = 98%


K N O W L E D G E


11 14 15 23 12 5 4 7 5 = 96%


But,


A T T I T U D E


1 20 20 9 20 21 4 5 = 100%


And,


B U L L S H I T


2 21 12 12 19 8 9 20 = 103%


So, it stands to reason that hardwork and knowledge will get you close, attitude will get you there, but bullshit will put you over the top.


And look how far .........


A S S K I S S I N G


1 19 19 11 9 19 19 9 14 7 = 118%


will take you.








Philosophy 101


A professor stood before his Philosophy 101 class and had some items in front of him. When the class began, wordlessly, he picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls. He then asked the students if the jar was full? They agreed that it was.


So the professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles, of course, rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.


The professor picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He then asked once more if the jar was full. The students responded with a unanimous - - yes.


The professor then produced two cans of beer from under the table and proceeded to pour the entire contents into the jar effectively filling the empty space between the sand. The students laughed.


"Now," said the professor, as the laughter subsided, "I want you to recognize that this jar represents your life. The golf balls are the important things - - your family, your partner, your health, your children, your friends, your favorite passions - - things that if everything else was lost and only they remained, your life would still be full."


"The pebbles are the other things that matter like your job, your house, your car. The sand is everything else - - the small stuff."


"If you put the sand into the jar first," he continued, "there is no room for the pebbles or the golf balls. The same goes for your life. If you spend all your time and energy on the small stuff, you will never have room for the things that are important to you. Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your partner out dancing. Play another 18. There will always be time for me to go to work, clean the house, give a dinner party and fix the disposal."


"Take care of the golf balls first -- the things that really matter. Set your priorities. The rest is just sand." One of the students raised her hand and inquired what the beer represented. The professor smiled. "I'm glad you asked. It just goes to show you that no matter how full your life may seem, there's always room for a couple of beers!





Worthy of Heaven


A man appears before St. Peter at the pearly gates. "Have you ever done anything of particular merit?" St. Peter asks.


"Well, I can think of one thing," the man offers. "Once, on a trip to the Black Hills, out in South Dakota, I came upon a gang of high-testosterone bikers who were threatening a young woman.


I directed them to leave her alone, but they wouldn't listen. So I approached the largest and most heavily tattooed biker.


I smacked him on the head, kicked his bike over, ripped out his nose ring and threw it on the ground, and told him,


'Leave her alone now or you'll answer to me.'"


St. Peter was impressed.


"When did this happen?"


"Just a couple of minutes ago."





Philosophy of Hypocrisy and Ambiguity


1. Don't sweat the petty things and don't pet the sweaty things.


2. One tequila, two tequila, three tequila, floor.....


3. Atheism is a non-prophet organization.


4. If man evolved from monkeys and apes, why do we still have monkeys and apes?


5. The main reason Santa is so jolly is because he knows where all the bad girls live.


6. I went to a bookstore and asked the saleswoman, "Where's the self-help section?" She said if she told me, it would defeat the purpose.


7. What if there were no hypothetical questions?


8. If a deaf person swears, does his mother wash his hands with soap?


9. If someone with multiple personalities threatens to kill himself, is it considered a hostage situation?


10. Is there another word for synonym?


11. Where do forest rangers go to "get away from it all?"


12. What do you do when you see an endangered animal eating an endangered plant?


13. If a parsley farmer is sued, can they garnish his wages?


14. Would a fly without wings be called a walk?


15. Why do they lock gas station bathrooms? Are they afraid someone will clean them?


16. If a turtle doesn't have a shell, is he homeless or naked?


17. Can vegetarians eat animal crackers?


18. If the police arrest a mime, do they tell him he has the right to remain silent?


19. Why do they put Braille on the drive-through bank machines?


20. How do they get deer to cross the road only at those yellow road signs?


21. What was the best thing before sliced bread?


22. One nice thing about egotists: they don't talk about other people.


23. Does the Little Mermaid wear an algebra?


24. Do infants enjoy infancy as much as adults enjoy adultery?


25. How is it possible to have a civil war?


26. If one synchronized swimmer drowns, do the rest drown, too?


27. If you ate both pasta and antipasto, would you still be hungry?


28. If you try to fail, and succeed, which have you done?


29. Whose cruel idea was it for the word "Lisp" to have "S" in it?


30. Why are hemorrhoids called "hemorrhoids" instead of "assteroids"?


31. Why is it called tourist season if we can't shoot at them?


32. Why is there an expiration date on sour cream?


33. If you spin an oriental man in a circle three times does he become disoriented?








Deep Thoughts #1


Gardening Rule: When weeding, the best way to make sure you are removing a weed and not a valuable plant is to pull on it. If it comes out of the ground easily, it is a valuable plant.


The easiest way to find something lost around the house is to buy a replacement.


Never take life seriously. Nobody gets out alive anyway.


There are two kinds of pedestrians -- the quick and the dead.


Life is sexually transmitted.


An unbreakable toy is useful for breaking other toys.


If quitters never win, and winners never quit, then who is the fool who said "Quit while you're ahead?"


The only difference between a rut and a grave is the depth.


Get the last word in: Apologize.


Give a person a fish and you feed them for a day; teach that person to use the Internet and they won't bother you for weeks.


Some people are like Slinkies . . . not really good for anything, but you still can't help but smile when you see one tumble down the stairs.








No Dirty Words


It is hard to find a joke without a dirty word or two in it. Here is one with none:


Two tall trees, a birch and a beech, are growing in the woods. A small tree begins to grow between them, and the beech says to the birch, "Is that a son of a beech or a son of a birch?"


The birch says he cannot tell. Just then a woodpecker lands on the sapling. The birch says, "Woodpecker, you are a tree expert. Can you tell if that is a son of a beech or a son of a birch?"


The woodpecker takes a taste of the small tree. He replies, "It is neither a son of a beech nor a son of a birch. It is, however, the best piece of ash I have ever put my pecker in."





Where This Word Come From


Did you know..... In the 16th and 17th centuries, everything had to be transported by ship and it was also before commercial fertilizer's invention, so large shipments of manure were common. It was shipped dry, because in dry form it weighed a lot less than when wet, but once water (at sea) hit it, it not only became heavier, but the process of fermentation began again, of which a by product is methane gas.


As the stuff was stored below decks in bundles you can see what could and did happen. Methane began to build up below decks and the first time someone came below at night with a lantern, BOOOOM!


Several ships were destroyed in this manner before it was determined justwhat was happening. After that, the bundles of manure were always stamped with the term "Ship High In Transit" on them which meant for the sailors to stow it high enough off the lower decks so that any water that came into the hold would not touch this volatile cargo and start the production of methane.


Thus evolved the term "S.H.I.T " , (Ship High In Transport)which has come down through the centuries and is in use to this very day.


You probably did not know the true history of this word. Neither did I. I always thought it was a golf term. !!!!!!!





10 things a man can do at Wal-Mart


Here are 10 things a man can do at Wal-Mart while his wife is taking her sweet time:


1. Get 24 boxes of condoms %26amp; randomly put them in people's carts when they aren't looking.


2. Get on the PA system and announce in an official tone: 'All cars in row 1 of the parking lot are illegally parked and will be towed. Will the owner of the cars please move them'. . and see what happens.


3. Make a trail of tomato juice on the floor leading to the ladies rest-room.


4. Get on the PA system and announce in an official tone: 'Code 3, Housewares' . . and see what happens.


5. Go to the Service Desk and ask to put a bag of M%26amp;M's on lay-away.


6. Move a 'CAUTION - WET FLOOR' sign to a carpeted area.


10. While handling guns in the Hunting Department, ask the clerk if he knows where the bullets and anti-depressants are.


12. In the Auto Department, practice your "Madonna look" using different sized funnels.


13. Hide in a clothing rack and when people browse through, say: "PICK ME!!! PICK ME!!!"


15. Go into a fitting room, shut the door and wait a while . . . then yell loudly: "There's no toilet paper in here!"

What do you think about this funny ideas?
Don't quit your day job.
Reply:This is all extremely funny but you have issues coming up with all of this? Very funny
Reply:This is so funny! Thanks for making me smile and laugh!
Reply:wow...were you bored? I thought they were funny though thanks for the pick me up!


tra la la la!
Reply:i love the 10 words! ahhahhaaa
Reply:My Favorite is Giving 100%!!!

edible flowers

Need help inVB express 2005 - program not working?

Public Class ColorsForm





'program Colors on page 324. Needs to create an array with upper bound of 50 and then increase the size of the array





' by 10 elements whenever it runs out of space to store the colors.





' Need to figure out how to increase the size of the array when the program is reading a file and runs out of room





Dim Colors(50) As String





Dim reccount As Integer





Private Sub ColorsForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load





Dim i As Integer = -1





Dim sr As IO.StreamReader = IO.File.OpenText("c:\DOCUMENTS and Settings\COLORS.txt")





Do While (sr.Peek %26lt;%26gt; -1)





i += 1





Colors(i) = sr.ReadLine





Loop





sr.Close()





End Sub





Private Sub brnColors_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnColors.Click





lstColors.Items.Clear()





For i As Integer = 0 To 50


If (Colors(i).Substring(0, 1) = txtState.Text) Then


lstColors.Items.Add(Colors(i))


End If


Next


End Sub





End Class

Need help inVB express 2005 - program not working?
You can try using the resize function.


http://msdn2.microsoft.com/en-us/library...





But I would suggest using an array list.


http://msdn2.microsoft.com/en-us/library...





You have much better control over your array.