

InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
101. |
Solve : I did it! Yay!? |
Answer» It's currently 12:08 at GMT-8 as I type this. When you write in C/C++/Java/Assembler/alltheothers, no additional stuff is required -- it runs on its own. I thought you needed at least the JRE to run Java programs / applets (~16-20Mb download from SUN). Quote *FrontPage is "one step removed" from writing HTML. The code it makes is a mess, and it usually causes only IE to render properly. Not my idea of fun. 100% accurate there. I'll take notepad over it any day. When you use any WYSIWYG system for programming or websites it usually makes it 100x harder to maintain (and understand the code) than if you went away and learned the HTML/Java/C(++)/etc... *Reads up on Java Oops! Oh well, the rest of my statement stands. As for WYSIWYG, Dreamweaver is fairly good at not totally botching up the code it makes. It's still hard to maintain, though. And I'd never use a C++ code generator; the mess of code it makes would be a nightmare. Side-Note: Do you know about the old compilers that would try to correct programmer's mistakes at compile time, so stupid things like forgetting a ; at the end of a line or missing a ) or two wouldn't cause a program that takes 5 minutes to compile to spit back an error instead of linking. It was a noble quest, but like most of mankind's projects it went way too far. One infamous example is a compiler that someone typed only one word into: "if". No INCLUDES, no "int main()", nothing. Would you believe that it created a 200-line command-line which successfully compiled and ran? Quote Side-Note: Do you know about the old compilers that would try to correct programmer's mistakes at compile time, so stupid things like forgetting a ; at the end of a line or missing a ) or two wouldn't cause a program that takes 5 minutes to compile to spit back an error instead of linking. Now if only you could do that with javac.... Then I wouldn't get pages of console text telling me I missed a couple of ;s. It ticks you off enough to check what you type before sending it to the "compiler". Especially when you have to ssh it to the server first as it's running a different version of Java.Sheesh, a suicide negotiator game? I think I lose by default.Nah, a monkey could beat it. You see, as long as the Suicide Meter is below 50% after five moves, you win a technical victory. It's really not hard at all, but it does include a lot of the things we covered in the Suicide unit at school, and it's playable and, for about a minute or so, interesting to play. Which is why I received an A+ stamped on the printed source code. (It's kinda hard to write the grade on a file...) For anyone interested, here's the program and the source code. Note that I didn't comment a single line, which is completely out of character for me, I assure you. The only reason for that is that I didn't ever... EVER... want to return to this program and modify it further. Only other thing to mention is that the dialog is rather cheesy. But hey, a week deadline is an hour or so of creativity. *grumble grumble* stupid 128KB attach limit... you'll have to compile the source code with Dev-C++ or a similar C++ compiler. But the compiled game is 130 KB -- 2 over the limit. :-/ [old attachment deleted by admin]You need this: http://upx.sourceforge.net/ It's so amazing. I got a game, with graphics included in the exe, to 114kb. And the guy on the other end doesn't need to do anything or have anything. He just runs like normal. Edit: On my compiler it is 68kb, and 16kb after upx.I wonder if I can attach a .7z file... Sweet! 104 KB! That's amazing... the uncompressed is 400+ KB... (pre-UPX and 7-zip) [old attachment deleted by admin]I like that game. Nice job there.Thank you! Again, I got it down to 16kb so I still win. |
|
102. |
Solve : Looking to show off your skills ??? |
Answer» Hello, |
|
103. |
Solve : cursor mania? |
Answer» Always wanted to know how cursor mania puts the cursor on your COMPUTER and SHOWS it even if your off the internet i will tell you where they files are. WELL so as people think u can do a search over your drive for .cur files which take ages the other way is follow me! |
|
104. |
Solve : Learning to program?? |
Answer» Hi all |
|
105. |
Solve : Compiling an VBScript to EXE? |
Answer» I have the following code and I want to compile it to an .exe instead of the standard .vbs, I know you should be able to do it with Visual Basic (I have Microsoft Visual Basic 2005 Espress Edition) but I don't know how, I tried several CONVERTERS on the web but NON of them really worked good. |
|
106. |
Solve : Direct3D device reset failed after multiple attempts? |
Answer» Hi, I have a problem with my computer where games freeze and I have to restart the computer via the button on the case. THOUGH with Command & CONQUER 3 I sometimes get this message when it seems like it is doing the freeze. |
|
107. |
Solve : capslock detector? |
Answer» hi to all! |
|
108. |
Solve : Visual Basic Command List? |
Answer» Hi IM Very new to programming And NEED a commands list for Visual Basic Express 2010 |
|
109. |
Solve : Question about BASIC (freebasic)? |
Answer» I need to know what the primitive types are for the LANGUAGE BASIC. I am running freebasic if it makes a difference. I can't FIND the information online anywhere. THank you in advance for the HELP.For a long time the types used in most BASIC compilers has been |
|
110. |
Solve : adding a usb drive? |
Answer» Hi Guys: Have a look in the /mnt directory to see what's listed there. You might also check the /media directory, which deals with automounted media in some distros. Use Nautilus or whatever file MANAGER your Debian INSTALL favours; alternatively, use a terminal window: Code: [Select]ls /mnt ls /media |
|
111. |
Solve : C++ trying to figure out how to clip file extensions for project? |
Answer» I have a project I am working on in C++ using VC++ 6 and I am reading in a text file that is output from a batch that runs a series of dir/b *.extension>>list.txt routines to append to file all file extensions I want to have in my list file instead of just all files in that directory. This is used to list all the movie/VIDEOS to this text file. The C++ is used to create/compile a HTML page for my HTPC. echo. <HTML><BODY>>>htpc.htmalthough I am not sure if escape characters would be needed to not confuse the batch with the < and > tags of the html, and the planting of the information in a looped process that performs line creation until eof of something similar to Quote echo. <a href"(variable [A] here to pass full filename and extension)">(variable here to pass the full file name without extension) [/url]>>htpc.htm/a instead of /url above within < > instead of [ ] ... this is being translated in this page LOL at using a sledgehammer to crack a nut... yah I guess that is a good analogy to what I was doing! I suppose I was using a sledgehammer because it will squash the nut, while I was unsure if batch was going to be like hitting the nut with a butter knife..lol ... Not to bash batches ability to get the job done, but I guess just using an overkill tool to get the job done because I was sure C++ would do it and unsure as to if batch could do it on its own without running into a limitation. I came up with this but it's useless and doesn't work for some reason. Code: [Select]REM output HTML file: setolocal enabledelayedexpansion SET outhtml=D:\htpc.html SET searchpath=D:\music\ echo ^<html^>^<body^>^<center^> > %outhtml% for /f "delims=*" %%P in ('dir /b %searchpath%*.mp3') do ( echo "%%P" call :separate %%P echo ^<A href="!searchpath!%%P"^>%FILE%^</a^> >> %outhtml% ) echo ^</center^>^</body^>^</html^> >>%outhtml% goto EOF :separate set FILE=%~n1 set EXT=%~x1 exit /b 0 :EOF You should stick with whatever you feel comfortable with... I prefer batch or other scripting languages (especially Powershell which (I don't personally think) has such a steep learning curve as some people make out) because you can run the thing and see if it works without having to compile it first. A thought: I expect you "normalise" your file names first so they don't look like this "Nightmare.on.Elm.Street.[XVID].REPACK.Superfly.mp4" where I guess you would isolate the extension by counting backwards from the end of the string until you hit a dot. (of course you wouldn't have files like that would you???!!! Because we're talking about fair-use format shifting of stuff we own. Of course. Anyhow Windows batch has "variable modifiers" (see the FOR help accessible via FOR /? for details) to help you get at file properties. If %%A is a file name then %%~dA is the drive letter (with colon) and %%~pA is the path (folder), %%~nA is the name part and %%~xA is the extension (with dot) so if you did this you would echo just the file names FOR /F "delims=" %%A in ('dir /b *.mp4') do ( echo %%~nA ) You can echo characters like < and > if you escape them with carets like this ^< so you could make a simple html file like this FOR /F "delims=" %%A in ('dir /b *.mp4') do ( echo %%~nA^ >> mymenu.html ) Code: [Select]S:\Test\movie list>dir Volume in drive S is USB-1 Volume Serial Number is 2C51-AA7F Directory of S:\Test\movie list 09/08/2011 21:16 <DIR> . 09/08/2011 21:16 <DIR> .. 06/06/2011 18:56 185,665,722 1307293768080.mp4 07/06/2011 18:36 168,581,204 1307401963926.mp4 14/06/2011 17:41 174,549,670 1308008220765.mp4 22/06/2011 20:40 401,292,105 1308705903296.mp4 09/08/2011 21:16 289 make-html.bat 17/05/2011 00:49 172,288,053 Mapa sonoro Antonia Font 16-05-11.mp4 09/08/2011 21:16 1,036 mymenu.html 07/05/2011 21:08 331,807,998 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_10_b010w7m9_default.mp4 03/04/2011 09:55 313,634,325 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_1_b01075w0_default.mp4 03/04/2011 10:00 332,694,729 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_2_b01083xt_default.mp4 10/04/2011 10:32 321,423,288 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_3_b0109bll_default.mp4 10/04/2011 10:41 329,109,128 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_4_b0109bln_default.mp4 17/04/2011 15:46 334,111,133 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_5_b010j4ms_default.mp4 17/04/2011 15:51 348,788,609 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_6_b010j4mv_default.mp4 30/04/2011 21:23 327,717,522 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_7_b010p4x2_default.mp4 30/04/2011 21:27 323,716,560 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_8_b010p4x4_default.mp4 07/05/2011 21:05 314,839,606 Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_9_b010w7m7_default.mp4 17/05/2011 00:49 172,288,053 test.mp4 18 File(s) 4,552,509,030 bytes 2 Dir(s) 237,718,470,656 bytes free Code: [Select]echo off echo ^<html^> > mymenu.html echo ^<body style="font-family:Arial; font-size:18px;margin-left:50px"^> >> mymenu.html echo Movie List^</br^> >> mymenu.html FOR /F "delims=" %%A in ('dir /b *.mp4') do ( echo %%~nA^</br^> >> mymenu.html ) echo ^</html^> >> mymenu.html Code: [Select]S:\Test\movie list>type mymenu.html <html> <body style="font-family:Arial; font-size:18px;margin-left:50px"> Movie List</br> 1307293768080</br> 1307401963926</br> 1308008220765</br> 1308705903296</br> Mapa sonoro Antonia Font 16-05-11</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_10_b010w7m9_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_1_b01075w0_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_2_b01083xt_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_3_b0109bll_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_4_b0109bln_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_5_b010j4ms_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_6_b010j4mv_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_7_b010p4x2_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_8_b010p4x4_default</br> Spiral_Series_3_-_The_Butcher_of_La_Villette_Episode_9_b010w7m7_default</br> test</br> </html> Quote from: BC_Programmer on August 09, 2011, 01:52:18 PM I came up with this but it's useless and doesn't work for some reason. Code: [Select]'setolocal' is not recognized as an internal or external command, operable program or batch file. No comment... Code: [Select]The syntax of the command is incorrect. S:\Test\movie list>for /f "delims=*" %P in ('dir /b S:\Test\movie list*.mp4') do You want the open parenthesis on the same line as the DO Code: [Select]REM output HTML file: REM not needed! setlocal enabledelayedexpansion SET outhtml=D:\htpc.html REM I changed this to suit my test folder SET searchpath=%cd% echo ^<html^>^<body^>^<center^> > %outhtml% REM OK now I ut a backslash in for /f "delims=*" %%P in ('dir /b "%searchpath%\*.mp4"') do ( echo "%%P" REM Colon is not obligatory REM You can do this inline anyhow call separate %%P echo ^<A href="%searchpath%%%P"^>%FILE%^</a^> >> %outhtml% ) echo ^</center^>^</body^>^</html^> >>%outhtml% REM Gotta skip over the sub somehow goto end :separate set FILE=%~n1 set EXT=%~x1 REM This is how you get out of the sub REM There isn't actually a label CALLED :EOF REM This MEANS RETURN REM This colon is obligatory goto :EOF :end REM We're done Code: [Select]<html><body><center> <A href="S:\Test\movie list1307293768080.mp4"></a> <A href="S:\Test\movie list1307401963926.mp4"></a> <A href="S:\Test\movie list1308008220765.mp4"></a> <A href="S:\Test\movie list1308705903296.mp4"></a> <A href="S:\Test\movie listMapa sonoro Antonia Font 16-05-11.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_10_b010w7m9_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_1_b01075w0_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_2_b01083xt_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_3_b0109bll_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_4_b0109bln_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_5_b010j4ms_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_6_b010j4mv_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_7_b010p4x2_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_8_b010p4x4_default.mp4"></a> <A href="S:\Test\movie listSpiral_Series_3_-_The_Butcher_of_La_Villette_Episode_9_b010w7m7_default.mp4"></a> <A href="S:\Test\movie listtest.mp4"></a> </center></body></html> but it doesn't work in my browser... Thanks Salmon for showing me how to do that in batch. I have gone in and changed my file names manually for many of the MP4's since some were created as DVD_unknown.mp4 for example and then I have to go in and type Cheech_And_Chong__Things_Are_Tough_All_ Over.mp4 and switch like Terminator4x3.mp4 to just Terminator.mp4. I am using Format Factory to generate many of my MP4's off of my DVD collection and it worked really well for about 95% of my movies. Other DVD's that don't like it I can use my capture card and software in the HTPC to act like a DVR to play to the HTPC from my DVD player and create the MP4 the long way for my home theater setup. The DVD's and VHS tapes then go into storage and I have my entire movie collection on a 500GB drive which is currently about 200GB. My wife the one day said oh, well since you converted those movies we can now get rid of them and sell them... I SAID NOOOO WAY!!! Its Piracy if we dont retain ownership of the movies! So we legally have to keep physical posession of them for as long as we own the digital copy of it. She agreed then to let the box of movies stay in the closet untampered with..lol So I am only creating "Fair-Use" Format Shifted COPIES! Most movies are about 700MB to 1.2GB in size created as 720 format. Since I only have a 32" screen 720 is fine. Since I want to know how to do it in both Batch & C++ now, and have some compile errors in C++, I am going to continue this thread with the errors I got with BC's code to figure out why I am having compile issues. It might be as simple as my compiler is different than BC's. I ran into a problem years ago when i was writing C++ in both Borland 4.0 that I owned which came bundled with a Borland book, and MS VC++ 5.0 that the college owned at the time in which one liked the header or handler I think its called #include and the other preferred #include...so i tried to remove the .h from #include since the rest were without .h and got a single error of windows not found or something along those lines. Also went and added .h to those without.h to make all the same statement style and it then gave me like 13 errors instead of 4 compiling. So below is the error I get that maybe you can point me in the right direction to resolve since it doesnt look very straight forward to me as a error of missing a ; etc would be. I have never used the Windows.h header/handler before so maybe I need to do something other than just copy/paste and compile. In the past with other programs calling out to custom .h files, I remember having to go in and build .h files to be present for the compilation when it links it to the main program. I have never written my own .h file to link to and mainly have coded within the console programming C/C++ environment as taught in college. I kind of feel like I was passed through the system when it comes to C++ programming as for in advanced C++ we were only dealing with CLASSES. Leaving college with a Computer Systems Management (MIS) Degree and favoring C++ over other languages and digging into the more advanced stuff, i feel as if they should have covered classes when I took the 2nd course Intermediate C++, then really dove into the advanced stuff in the advanced C++ the 3rd semester to go into stuff like what BC has coded here that is new territory and I am soaking up as much info as I can from it. The other thing I need to do is stay active with it too instead of just coding when I need something, since if you dont use it you lose it. Similar to how I passed advanced math with calculus and loved trig, and when going to assist a friend with his math the one day after not doing it for almost 10 years, I knew some stuff right off, but other stuff I was like hmm...lets look it up..lol If I played with it after learning it, I would have retained it better and programming is the same way I feel. Quote --------------------Configuration: htpc3 - Win32 Debug--------------------Compiles in VC++ 2008. Your problem (assuming it isn't also related to compiler versions) is that your defs are set to use ANSI rather than Unicode. I think that is the default for earlier versions of the MS compiler. This breaks the assumption that fdata->cFileName is a WCHAR_T, as well as others. enter #define UNICODE before the windows.h include. Quote The other thing I need to do is stay active with it too instead of just coding when I need something, since if you dont use it you lose it.I hardly ever write C++ code, personally. I know what you mean but I don't think it applies as strongly as you think. There is certainly no reason to shoehorn projects into a C++ mould.Thanks BC I'll give that a try on my VC++ 6.0... I figured it was compiler version related. Never knew about the ANSI vs Unicode change. I have been tempted to install a newer version of MS C++ such as 2008 Express which came bundled with my VC++ 2008 Book, but the clunker workhorse laptop I use while on breaks at work is a Pentium III 600Mhz with 384MB Ram running clean unpatched oem install of XP Pro SP2, and patching it to SP3 and all updates for a laptop that remains as offline usage brings it to a horrible crawl, so I figured going through installing 2008 and Dot NET etc might be too much for it to handle. I have VC++ 2008, VB 2008, and C# 2008 installed on my desktop home computer and played with them some. Only complaint I have with them is that whatever you write you need to make sure that Dot NET 3.5 I think the version is is installed on any system that you execute the compiled programs from. Its too bad they cant squeeze that into the .EXE so it can be stand alone I guess you could call it vs requiring the 3.5 framework that most systems I have seen dont normally update to with MS updates. I think the MS updates bring systems to Dot NET 2.0. Salmon... I tried your batch and tweaked it some to work on my system which is executing it on C: instead of D: and the problem I am seeing same as what your output shows is that the instruction to pass %FILE% into the created HTML line that is written to HTPC.htm seems like its not getting populated with the File Name information. For some reason, %FILE% in the line below isnt inherriting the file name from set FILE=%~n1 so because of this the page loads as an empty page with no text linked when you load the htpc.htm page. Code: [Select]echo ^<A href="%searchpath%%%P"^>%FILE%^</a^> >> %outhtml%Here is what is created from the batch when changing SET outhtml=D:\htpc.html to SET outhtml=C:\htpc.html since my D: drive is my DVD drive. I also have to change SET searchpath=%cd% to SET searchpath=%cc% , which was a guess on my part that the "d" meant D: drive and so the last "c" would be C: drive, and that gives me the output of Code: [Select]<html><body><center> <A href="test1.mp4"></a> <A href="test2.mp4"></a> <A href="test3.mp4"></a> </center></body></html> Instead of Code: [Select]<html><body><center> </center></body></html> so I end up with what you get...so still stuck at %FILE% not POPULATING with the File Name without the extension portion. Once this file name issue is fixed for populating %FILE% we should end up with Code: [Select]<html><body><center> <A href="test1.mp4">test1</a> <A href="test2.mp4">test2</a> <A href="test3.mp4">test3</a> </center></body></html>the batch you used there was the one I originally created, with his modifications. As he noted, it doesn't work. I don't think it is worth fixing since he already offered a batch solution. Quote from: DaveLembke on August 09, 2011, 06:52:28 PM Only complaint I have with them is that whatever you write you need to make sure that Dot NET 3.5 I think the version is is installed on any system that you execute the compiled programs from. Its too bad they cant squeeze that into the .EXE so it can be stand alone I guess you could call it vs requiring the 3.5 framework that most systems I have seen dont normally update to with MS updates. I think the MS updates bring systems to Dot NET 2.0.And yet, nobody seems to consider the necessity of a JVM and the Java class libraries being installed to run java programs as a point against Java development. Almost every Development tool will require something of the host machine in the way of libraries for any non-trivial project. All Versions of Visual Studio .NET allow you to target a different framework version. You can create programs that target .NET 2.0 in Visual Studio 2008. I don't, because there is no point. If somebody doesn't have .NET 3.5 installed, they can install it. I'm not about to do more work getting things working with .NET 2.0 just so somebody can be lazy; additionally, Windows Vista and 7 come with .NET 3.5 anyway, and I don't make a habit of targeting 10 year old Operating Systems. Also of interest: if you do it right, you can create executables that run on both Windows, OSX, and Linux using .NET. Which is an advantage. Quote from: DaveLembke on August 09, 2011, 06:52:28 PM I also have to change SET searchpath=%cd% to SET searchpath=%cc% , which was a guess on my part %cd% is a special Windows-supplied variable - it holds the drive letter and path of the current directory at the time the code is run. %cc% will presumably just be blank. Anyhow as BC_P said, I was just playing around with his code. You could try the code in my post, the one which starts "You should stick with whatever you feel comfortable with..." but on that note, it may be that going into batch was a step in the wrong direction, and I apologise for hijacking the thread to no good purpose. Quote from: DaveLembke on August 08, 2011, 08:29:30 PM So I figured, I'd run a quick batch, then have my list.txt file ready for me with the files I want to have included in the created HTPC webpage and then use the C++ to then read in this text file and run with it. You could just modify the batch you run first. Instead of this... dir /b *.mp4 >> list.txt ...you could use this, which does the same thing except it strips off the .mp4 extension: for /f "delims=" %%A in ('dir /b *.mp4') do echo %%~nA >> list.txt |
|
112. |
Solve : Cmd sleep command? |
Answer» Hey, Hmm who the .... Reads the terms of rules or shizzle... :/ You, if you want to stay here. Quote :elite i find the function NAME funny; elite... are you serious? go read a book |
|
113. |
Solve : .bat runas? |
Answer» Hello all, |
|
114. |
Solve : Computer Firewall bypass? |
Answer» Im at schooll and me and a few friends of mine are ATTEMPTING to use tel net to bypass our schools FIREWALL we need a port number to an anomity site or h.e u spell it. |
|
115. |
Solve : Compiler Construction: Design A Scanner? |
Answer» Hi guys, Well i don't KNOW whether this is the right place to ask this question with regards to compiler. but i hope someone can HELP or direct me to a site that might help. |
|
116. |
Solve : Input validation? |
Answer» Hi, Hi,input, AFAIK, can mean the input arguments to a function/procedure or the script arguments, or user input. To validate means to check them according to your predefined set of "rules". For example to get the user to key in a number (because you wanted them to) when they run your script, you can use the raw_input() and isdigit() function like this CODE: [Select]userinput = raw_input("Please ENTER a number: " ) if userinput.isdigit(): # <-- this is considered a validation. print "You entered a number, good" else: ...blah... The above example stores what the user keys in into variable userinput. Then the isdigit() method checks whether its a digit. This is called validation. Its the same for other types of inputs. Thank you so much Ghostdog74, That has helped alot. |
|
117. |
Solve : C++ questions? |
Answer» i got a few questions on C++ Came across [highlight]your Forum[/highlight] while browsing around…cool stuff u have going on here.? Odd. I don't think it's a SPAM bot either, seems like a real user. Anyway, they'll get spammed . . . alpa, I recommend you remove your email address from your post.Done.weird people across the forum...Nice editing Dilbert, haha. And lordoftheplat . . . I agree. |
|
118. |
Solve : Changing Windows Product Key in VB 2005? |
Answer» I have already managed to WRITE the code to RETRIEVE the key so I can see it, but how can I change the product key, thanks in advanced. |
|
119. |
Solve : Interesting read? |
Answer» http://www.reed.edu/~tuckers/jokes/foot.html Shooting yourself in the foot with VARIOUS programming languages/interpreted languages. Anyone who's CODED Hello World or better should LOVE this. LOL, NICE find. |
|
120. |
Solve : need some programming advise? |
Answer» so i was wondering... |
|
121. |
Solve : .bat file bombing out - trying to move files acros? |
Answer» This batch job (below) sits on a server that calls a server in a REMOTE location. The remote server then calls a server in a different remote location. I am trying to move images using a single batch file. All of the servers have permissions on each other. |
|
122. |
Solve : Automated copying and scheduling over LAN? |
Answer» Hey All, One script (or something) that will run from the host computer, and copy files from the shared folder to a dir on root (C:\) for each computer on the network (I think 14 PCs). Once it has copied the files/folder, I would want it to automatically delete any scheduled tasks, and create a new task that addresses EXAMPLE.exe to run on specified night from X to Y times. I think the easier way would actually be to do it backwards. Make a share on the host computer which contains the video file. Then map a network DRIVE on each of the clients. Make a script that simply copies the file from the network drive (ex: drive Z:) to drive C: and plays it. Put that script on the network drive and add it as a scheduled task on each of the comps. And look here if you need help with with the scheduled tasks command: http://www.robvanderwoude.com/schtasks.phpLinux711, thank for the link. Looks interesting.For automated copying/mirroring, I use Unison. Might help out with your needs? http://www.cis.upenn.edu/~bcpierce/unison/ Works cross platform - I use it to keep a directory on one of my Linux servers at home synchronised with a directory on a PC at work. |
|
123. |
Solve : To get RAM and CD-ROM serial number? |
Answer» ANYONE knows how to get SERIAL number for RAM and CD-ROM using vb.net? THANK you very much. |
|
124. |
Solve : How to monitor COM1 port? |
Answer» I need to know what does a PROGRAM when i launch it regarding to COM1 port. |
|
125. |
Solve : hi.? |
Answer» how can i make a program USING LINKE LIST with the implementation of hashing?What programming language might we TALKING about here? |
|
126. |
Solve : how can i hack into someone computer using there i? |
Answer» i have someone IP adress and i would LIKE to know how can i HACK into there COMPUTER to see what there doingI suggest hackerhope.com. |
|
127. |
Solve : Re: DB Structure for Travel web site? |
Answer» Sounds like you have a candidate for splitting the data into multiple, RELATED TABLES. What sort of database are you using? (i.e. MS Access, SQL, ETC.) Incidentally, re speed - correct table design/separation within a relational database environment, coupled with good SQL query design, will undoubtedly speed up your searches. Think in terms of fractions of a SECOND for a completed query.I'm afraid I have no experience with Sybase or JSP. I ould do the database design, but I would need a FULL spec, and that kind of work doesn't come free, not even from nice people like me! Sorry... :-/Wow, don't you just love it when the ORIGINAL posters question goes missing. |
|
128. |
Solve : Batch files help please!? |
Answer» hi, i was wondering if when CREATING a batch file i could give it a COMMAND to open internet explorer, but to open IE with a site, such as google. |
|
129. |
Solve : 'else' does not execute? |
Answer» I've written this little program that lets you input a number and the output declares whether it is positive or negative, but want it so that if you enter characters it displays an error. I'm trying to do that with the LAST 'else' statement, but it doesn't work. Can anyone point me in the right direction? Code: [Select]IMPORT java.util.Scanner; public class Positive { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num; System.out.println("Enter number"); num = input.nextInt(); if (num < 0) { System.out.println("This is a negative number"); } else if (num == 0) { System.out.println("Zero"); } else if (num > 0) { System.out.println("This is a postive number"); } else { System.out.println("Please enter a valid number"); Thanks in advanceYou seem to be missing a curly bracket. Or else leave out the curly brackets completely, which only works if you've got a one-line statement. I'm assuming this works in Java - like you I've only started learning it myself. It does work in PHP though. EDIT: after searching it appears you need to add a try/catch statement to catch the error. catching the exception is one WAY: Code: [Select]import java.util.InputMismatchException; import java.util.Scanner; public class positive { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num; System.out.println("Enter number"); try { num = input.nextInt(); if (num < 0) { System.out.println("This is a negative number"); } else if (num == 0) { System.out.println("Zero"); } else if (num > 0) { System.out.println("This is a positive number"); } } catch(InputMismatchException ime) { System.out.println("Error: Invalid number"); } } } But it's not really the "best" way... best of course being subjective. Generally, if you can do something without raising and catching exceptions, you should. in this case, it's the hasNextInt() function. Code: [Select]import java.util.InputMismatchException; import java.util.Scanner; public class positive { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num; System.out.println("Enter number"); if(input.hasNextInt()) { num = input.nextInt(); if (num < 0) { System.out.println("This is a negative number"); } else if (num == 0) { System.out.println("Zero"); } else if (num > 0) { System.out.println("This is a positive number"); } } else{ System.out.println("Invalid number"); } } } and here's my pointlessly reduced version. Code: [Select]import java.util.Scanner; public class positive { public static int Sign(int argument) { return argument<0?-1:argument==0?0:1; } public static void main(String[] args) { Scanner input = new Scanner(System.in); int num; String[] resultmessages = new String[] {"This is a negative number", "Zero","This is a positive number"}; System.out.println("Enter number"); if(input.hasNextInt()) { num = input.nextInt(); System.out.println(resultmessages[Sign(num)+1]); } else System.out.println("Error: Invalid number"); } } Quote from: Salmon Trout on October 02, 2011, 06:18:23 AM You seem to be missing a curly bracket. Yes, i didn't copy the end main and end class brackets BC, i like your second option because it pretty close to what mine is, except it does work. Quote from: reddevilggg on October 02, 2011, 02:18:07 PM BC, i like your second option because it pretty close to what mine is, except it does work. eejit i am, it supposed to read, does NOT work. The second option does NOT work. It works fine for me. If you are copy-pasting into yours to try it, rename the file to positive.java or change the name of the class from positive to Positive. (the latter is a lot easier on windows). Quote from: BC_Programmer on October 03, 2011, 10:16:59 AM change the name of the class from positive to Positive. Of course, i missed that. Works perfect, thanks again. |
|
130. |
Solve : House Escape -- an old-style Adventure Game? |
Answer» Hello, with more to come as I add more functions, fix problems I know exist, and do a final code check before I let the compiler spew errors at me. Waiting until the end for a compile can be overwhelming and very disheartening. If you write your program modularly, I suggest you compile after each function is complete and fix the errors as you go. One advantage is you can concentrate on the logic more and not the syntax so much. Just a thought. 8-) Trouble is, the only code I'm actually concerned about is the code that links up with other classes and their member functions. I'd have to make a mock class system just like the one I'm making, and that would be equally time-consuming. In a normal program I couldn't agree more. But a game, the way I have it, won't work with that very well. I wish it did. Oh well, good to know for next time. OK the impression I get is that you're writing code but have yet to test if it works? Please tell me that is not true... Also that seems like a very large amount of functions. I don't want to rain on your parade (I've never used that phrase before) but I have a feeling your code is too specific and not very modular Ask yourself this question: after completion, how easy would it be to add a new possible command, or a new room? If it would take hours of function writing and modification..... well at least you have learnt for next time I look forward to seeing your code!It is true, I'm afraid. As for adding new commands, or a new room, that would be easy enough. In fact, that's next on the agenda; a couple of new commands that hopefully add a little to the game. However, adding a new room is just a tad more time-consuming. Erring on the side of allotting too much time per task, setting up the class in the header with all the needed function prototypes would take about 15-30 minutes, depending on the number of objects. Implementing the room would take about 5 minutes per function. Getting other rooms to "hook up" to the room would take about 30 seconds per room that needs connection (copy-paste, change the target room). Assuming an average of two objects in a room, and one way to implement each, CREATING a new room should take, at most, an hour. Addressing the large number of functions: It's not as much as it seems. I can break it down: The first obstacle is leaving my room. The player needs to collect two items, after doing one thing, and use them, in order to leave it. There's also a function designated to an action that seems reasonable, but won't, in this game, work. That's two items to put in inventory (one func each), one func for the first action needed, one for the action that doesn't work, and two each to implement the items. That's 6 functions right there. Then, there's the one to leave my room, making 7. Finally, there's a "description" function for a "look around" command, private variable accessors, and the constructor and destructor. That makes 14 in the first room. However, not all the rooms are this intensive. The Guest Bathroom, for example, has only 7, including constructor, destructor, and all item or room-related functions. I think that one's got the fewest functions. Actually, I think [game detail hidden] is the room with the fewest functions; it's actually got 12 total, but 4 or 5 are, like any command-line game, red herrings. On average, I have about 9 functions per room, including every way to use an item, the constructors, etc.. However, I've got 11 rooms going, here. That makes appx. 99 functions, and let's not forget the parser which is the backbone of the whole thing. In the interest of making the code easier to read, it's one parser/room. No big deal, it just takes more space that way. (And also solves the problem of a command doing one thing in one room, and a totally different one in another room.) Sorry to rant, I got carried away. Anyway, I'm getting to it again. Oh dear.... I hate to break it to you, but your design sucks You have basically hard-coded all your rooms and actions and now you FACE the consquences. Never mind a function for each item, you should have one function for all items....I'm not quite following you, here. :-?I'll wait til I see your code, then see what I can suggest Sounds good. I am looking for help, here, so as soon as it's done I'll take all the help I can get. It probably does suck, though. Oookay, I knew that my code sucked, but this is ridiculous. I got a thousand errors, and I'm rewriting. EDIT: Before I go on, I should ask: If I have a member function of class X, how can I access the member variables of class Y? That seems to be a place it was hanging up the compiler.Neil is right Dilbert, when writing a program, you should perodically compile it, to make sure there are no errors, then fix any errors as you go along. Sorry I am a noob at C++ so I couldn't really help you with that, now Java on the other hand I could help you with.I found out one of the big problems. A little late, but I did. As it happens, I needed to access an accessor in another function in an if statement. Trouble is, I was doing this: Code: [Select]class X { public: //Other member functions bool getVar() const { return theVar; } //More stuff private: bool theVar; }; class Y { //Stuff void myFunc(); //Obviously, I wouldn't ever use these classes and function names. }; ... void Y::myFunc() { if(Ben.getVar()) { //Stuff } } ... int main() { X Ben; Y George; George.myFunc(); ... } Imagine my frustration when I found out that I only needed to do this: Code: [Select]class X { public: //Other member functions bool getVar() const { return theVar; } //More stuff private: bool theVar; }; class Y { //Stuff void myFunc(); //Obviously, I wouldn't ever use these classes and function names. }; ... void Y::myFunc(X Ben) { if(Ben.getVar()) { //Stuff } } ... int main() { X Ben; Y George; George.myFunc(Ben); ... } I was doing that originally, but I forgot why after a week-long break, so I removed them as I couldn't find a reference on it. However, I discovered this a little late: I'm sick and I was upset, so I ended up using Shift-Delete on the hpp and cpp. Smooth move, Dil-man. I have a backup from my flash drive (yay!) and I will have about 70% of what I wrote back. But I'm isolating and testing the tBedroom sequence now in a separate hpp/cpp combo. I think this one will compile. As it were, I lost a good chunk of my parser and int main(). This supports Scott Adams' theory: "People are idiots. That's everyone, not just the people with low SAT scores . . . idiocy is a condition that people slip into and out of every day. --Scott Adams, The Dilbert Principle As it were, I've got the cold and the flu, so debugging my bedroom will wait for a while. I've got all day tomorrow... I'm staying home sick. You need this: http://en.wikipedia.org/wiki/Test-driven_development |
|
131. |
Solve : remove program? |
Answer» hi, i recently downloaded an antivirus program shareware,from NORMAN.COM.(not norton)i didnt like it so i tried to remove it from add/remove programs nothing happend?so i went to my computer c:/docu-settings/paul. hi,dilbert. thanks for your time.hi,Dilbert ive tried safe mode and it says access denied can not delete bin, norman write protected or in use???in the properties list it is read only i could not CHANGE this(still in safe mode)i will end up rebooting from install cd and wipe the disc clean cause i dont know if it is hacker getting my bank details...cheers..........(unless THERES another way)Oh, I'm not done with this yet. Slippery program, this one... Perhaps the prompt can help with this one: Start > Run Type "CMD" (no quotes) and click OK. Type the following commands: cd \ cd Program Files\Norman (<-- Replace "Norman" with the name of the folder that has Norman in it) attrib -r -a -s *.* /s /d del *.* Let me know if that works. Quote Oh, I'm not done with this yet. Slippery program, this one... Perhaps the prompt can help with this one:hello,Dilbert i tried the cmd prompt (if i did it properly( NOVICE) it said system can not find the patch specified? i found this,if it helps.Norman css MIB file unknown? i appreciate your help but i dont want to do your head in,do you think it is a hacker?if so ill wipe the disk clean.I don't think it's a hacker. I do, however, think that we've got a really stubborn program, here. I've got one last thing to try. Download a free program called Ccleaner from here: http://www.filehippo.com/download_ccleaner/ Run it, and go to the button marked "Tools". Find the Norman program, and click "Run Uninstaller". Then click on "Issues" and run a scan. Quote I don't think it's a hacker. I do, however, think that we've got a really stubborn program, here. I've got one last thing to try. hi,Dilbert.thanks for the ccleaner..last night i wiped the disc (saved my stuff to cd)up all night,, many thanks for your time on this one,at least ive found a good help forum!!!cheers p Quote I don't think it's a hacker. I do, however, think that we've got a really stubborn program, here. I've got one last thing to try. Hi ...I downloaded this program before but didnt use it because I didnt know if it was safe to. After you run analyze...do you just click on run cleaner and let it remove all that is listed? or do you have to go through the list and make SURE its not deleting anything important...because I have no idea what all those things mean. Quote Hi ...I downloaded this program before [highlight]but didnt use it because I didnt know if it was safe to.[/highlight] After you run analyze...do you just click on run cleaner and let it remove all that is listed? or do you have to go through the list and make sure its not deleting anything important...because I have no idea what all those things mean. Surely it is safer than what you DID download. Quote
Hello lana. Yes, click on Run to allow CCleaner to delete the items listed. I have never heard of any problems using CCleaner & regularly use it myself. Perhaps you could note a few items and do some investigating as to their use, just for interest sake. However there are no 100% guarantees with anything. Good luck |
|
132. |
Solve : Shopping Cart problem? |
Answer» OK I have a quaetion. I need a shopping cart program, but I am not SURE how to go about this. DO I need to make CODE up for this, or there is a program out there for it. Im not sure were to go from here and I could use some help with this please. Thanks for your hrlp!!!!!ASSUMING your server SUPPORTS php, asp, etc.... You have two options. |
|
133. |
Solve : How to interact with BIOS/CMOS through VB.net? |
Answer» Dear all, I need to develop a VB.net application which can interact with BIOS to display the PC Health Status You might want to check out the Win32_TemperatureProbe class which has nothing to do with the BIOS but might prove helpful. 8-)I tried Win32_TemperatureProbe, but it returns nothing!From what I could DISCOVER, the System Management BIOS REFERENCE Specification is only implemented by some motherboards. Accessing SMBIOS with WMI and the CIM data model only works with WinXP-Pro and Win2003 Server. This article may help: SMBIOS You could check with your motherboard manufacturer for drivers that could read this info. You can check, but I'm fairly certain you won't find anything in the Windows API for this. Good luck. 8-) |
|
134. |
Solve : how can i block a URL in my browser? |
Answer» hi U out there.........is there any method to block the urls of sites to block'em VIEWING in browsers........like firefox....explorer....etcgo to C:\WINDOWS\system32\drivers\etc , open the host file with notepad. you can enter the sites you WANT in there, dont forget you need the IP address of the site which can be found from http://www.selfseo.com/find_ip_address_of_a_website.php |
|
135. |
Solve : Protecting the ENTIRE worksheet (excel 2000)? |
Answer» I am having a headache with Protection right now, as it doesnt seem to include the drop-down list created by Data Validation |
|
136. |
Solve : Deleting program? |
Answer» I created a PROGRAM about a year ago in C and i cannot figure out how to get rid of it when i try to delete it or move it an error MESSAGE comes up SAYING it is being used by another program and all it is is a simple I/O program anyone have any ideas? I would just let it be but it's on my desktop and that's already clutterd enough. ThanksPlease POST the exact message. Have you tried going into safe mode to delete this program? What exactly is on the desktop, a shortcut icon or the program file itself? |
|
137. |
Solve : Python 3.2.2 problem? |
Answer» Hello. In all honesty, I am asking for help on a homework problem. I've done all that I can on this program, but I still seem to be having trouble. Here is the problem, followed by what I have:
|
|
138. |
Solve : plz help..sql server and visual studio(i'ts urgent)? |
Answer» Hey Somebody has given me Human resource management system folder to connect with both sql server 2000 and visual studio 2008. 1.) SQL 2000 support has been dropped from all of VS, not just database projects. There is a cost to maintaining providers and the SQL 2000 Engine is much different than 2005 and 2008. With limited resources we have focused on 2005, 2008, 2008 R2 and the upcoming version of SQL.First answer on... http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/37d137be-f119-4d49-bddf-99f398328096/ |
|
139. |
Solve : Problem learning Java? |
Answer» I'm trying to teach myself Java and i'm going through some tutorial i've found on the internet, but i've become stuck. It asks to write a program that when you input a full name (first, middle and last name) it output the initials. So far i have this import java.util.Scanner; As you can probably see the output is the first INITIAL then the number of where the other to initials are. Can anyone help ?? Ive changed the middle bit to Char and it still doesnt work, i dont get it Quote String index = name.substring(0,1);indexOf and LastIndexOf return an int, what you need to do is get the character at that position. the variable "index" ought to be called 'first' to be consistent with the others. But that's more a style issue. for the middle name, you would use the mid VALUE you have: Code: [SELECT]String middle= name.substring(mid,mid+1); String lastname = name.substring(last,last+1); Naturally, you would change the final System.out.println() call to use middle and lastname instead of the numeric values. BC, thank you very much, that worked a treat, and know i understand where is was going wrong. I makes perfect sense now, YET an hour ago its was so frustrating. Thank you again Quote from: reddevilggg on September 28, 2011, 04:58:53 PM BC, thank you very much, that worked a treat, and know i understand where is was going wrong. I makes perfect sense now, yet an hour ago its was so frustrating. You're welcome Actually even I hit a snag with that otherwise simple snippet. Since I don't USUALLY use java, I use C#. The string class in C# is similiar, and the substring method is there, but it's arguments are the start, and the length you want, whereas Java takes the start and the end indices. Had me scratching my head trying to figure out why my test (which assumed start,length) wasn't working until I looked up the method in the documentation. |
|
140. |
Solve : mysql? |
Answer» i WANT to LEARN about MYSQL..how to do that?W3Schools.comwww.google.com/#hl=en&cp=8&gs_id=v&xhr=t&q=mysql+tutorial&pf=p&sclient=psy-ab&source=hp&pbx=1&oq=mysql+tu&aq=0&aqi=g4&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=d644b56267fbe23f&biw=662&bih=592 |
|
141. |
Solve : Web Browser VB.net? |
Answer» Hello, |
|
142. |
Solve : Learning C++? |
Answer» Hello, |
|
143. |
Solve : The VB6 method Inet1.OPENURL downloads just a piece of html code.? |
Answer» I used the VB6 method Inet1.OPENURL in a ROUTINE of mine, but I alwais obtain just a piece of the html code of the page I want to GET. Why? Thank you to all like answare. (excuse me for my bad english: I am italian).http://support.microsoft.com/kb/232194 |
|
144. |
Solve : Question about Java applets!? |
Answer» I'm helping out a friend with his website and he is using Extreme Tech Weather Station to detect the outdoor weather for his blueberry farm. The HELP I am giving him is creating an applet for the website that will display these results. There already is a Java Swing GUI that utiliizes these APIs, but I cannot get it to work as an applet at all. I can get the layout of it to display on the applet, but the functionality doesn't work at all. |
|
145. |
Solve : Help with Java Random Class for Double values 0-100? |
Answer» Hello, I am working on a class assignment for my Computer Science class I have been working on it this week and it is due Sunday and I am not able to discuss this with my instructor. This is part of a larger assignment and this is the part I am questioning. The instructions say: The cost of a given ROCKETSHIP will be in billions of space credits. The number should be displayed using a DecimalFormat object. Print the number of billions of space credits just like you would print dollars and cents. (For instance, 5.75 billion space credits.) The price of a rocketship will be between 3 and 20 billion space credits. To determine the price of a given rocketship, generate a random double between 0 and 100. If this number is less than 3.0, REPLACE its value with 3.0. If the randomly-generated number is greater than 20.0, replace its value with 20.0. Then use whatever number you arrive at (between 3.0 and 20.0) as the rocketship’s price. Here is the output I get: "Rocketship "Bob" costs 20.00 billion space credits." Here is sample output: "Rocketship "Ohio" costs 14.71 billion space credit" "Rocketship "Illinois" costs 20.00 billion space credit" I'm not SURE if this correct way to do this assignment Here is the code I wrote: //Randomly give the cost of the ships from a vaule of 0 to 100 costRandom = randomNumbers.nextInt(101); //If this number is less than 3.0, replace its value with 3.0. if (costRandom<3.0) { costRandom=3.0; } //If the number is greater than 20.0, replace its value with 20.0. else if (costRandom>20.0) { costRandom=20.0; } I tried: costRandom = randomNumbers.nextDouble(101); and it said there needs to be no arguments The problem is it only seems to print out just INTEGER values and not doubles. I understand if you feel you shouldn't help because it a school assignment. Let me know if you need to see the full code to understand. Thank you for any help you can give. This is Java? Quote randomNumbers.nextDoubleLooks like NET 4 instead. But in Java one would see Quote Random rand = new Random();Early in the code. Did I miss something?I am new to Java and may have made a mistake. I will show what I did. // Create a Random object. Random randomNumbers = new Random(); // Create a DecimalFormat object. DecimalFormat formatter = new DecimalFormat("0.00"); double costRandom; //Holds the cost of the ships //Randomly give the cost of the ships from a vaule of 0 to 100 costRandom = randomNumbers.nextInt(101); //If this number is less than 3.0, replace its value with 3.0. if (costRandom<3.0) { costRandom=3.0; } //If the number is greater than 20.0, replace its value with 20.0. else if (costRandom>20.0) { costRandom=20.0; } (earlier in the program I ask the user for a name) //Display Rocketship name ands its cost System.out.println("Rocketship \"" + r.Name +"\" costs " + formatter.format(costRandom) + " billion space credits."); Right now it is outputting a integer value for "costRandom" and I need it to output a double value so it have the ability to give both a integer and two decimal places in the output. I don't know how to turn it into a double.It would be nice to have a thing that souled just convert a integer into a double. I don't know the elegant way to do it, being that I am so lazy and In don't want to do a lot of research, I might just do this. Have an item that already is a double. Call it mydouble get the inter form the random thing 0 - 100 call it myinteger now say something like this: add myinteger to itself 5 times. Use a tmp if you wish. Now say mydouble = myinteger /5 dividing an integer forces a offloading point do-da-do. You have a real number in mydouble. Yeah, I know, not very elegant. First get it to work. Polish it later. Code: [Select]costRandom = (randomNumbers.nextDouble()*17)+3; Edit, Oh, I see they don't want you to do that. Code: [Select]costRandom = (randomNumbers.nextDouble()*100); if(costRandom > 20) costRandom =20; else if(costRandom < 3) costRandom=3; Or you want to be unnecessarily terse... Code: [Select]costRandom = (randomNumbers.nextDouble()*100); costRandom = costRandom > 20 ? 20 : costRandom < 3 ? 3 : costRandom; Quote from: Geek-9pm on October 22, 2011, 12:52:39 AM It would be nice to have a thing that souled just convert a integer into a double. Code: [Select]double doublevalue = (int)intvalue; Quote mydouble = myinteger /5As you said, you didn't do any research. the division in that expression would be integer division. dividing by 5.0 would force the literal to be a double, I think, thus making the division a floating point operation.Thanks, BC It is very hard for me to do research. I just use what I can.Thank you very much BC. The code you suggested below works great for what I needed to do. costRandom = (randomNumbers.nextDouble()*100); if(costRandom > 20) costRandom =20; else if(costRandom < 3) costRandom=3; |
|
146. |
Solve : perl write from array to text file issue? |
Answer» So reading in file to array is easy since it automatically assumes read all to eof. But when writing back, I GUESS you also need to tell it to write back all to end of array to the file, and so do I need to create an incremental loop writing back each value from the array until I hit nul or is there a better method? perl has lots of quick ways to shorthand get the job done. I was originally thinking it would be happy assuming to write all values from the array back, but it writes nothing to import2.txt |
|
147. |
Solve : Symbian S60 development in C++ help!? |
Answer» Hi. I have a Nokia 5230 Nuron which runs on the Symbian S60 5th Ed. OS. I've been wanting to for a while to start developing QT apps for it, so I just recently installed the Qt SDKs which CAME with Qt Creator as the IDE for it, and I also have App TRK and CODA on my phone for debugging on the phone, but the problem is that Qt Creator will not detect that my phone is connected at all. Under the project window and under which COM port to use, it remains blank. My computer detects my phone being connected no problem, but this is not working. Anyone who maybe has run into a similar problem before your help is HUGELY appreciated. WOW! That is an impressive set of tools. Sorry I am not help. ... successfully compiled and built the QT FRAMEWORK on my WINDOWS Laptop using MinGW C/C++ compiler and installed QT Creator 0.9 alpha as my IDE. I originally got complimation working with Eclipse but opted for QT Creator as it looks handy since it made especially for QT.As you can see, the workstation OS haws a impact on the use of serial ports. If it is Windows. You may wish to reconsider using USB instead.Thank you for your reply, geek-9pm. The OS I am running on my workstation is Windows 7 Professional 64-bit. Here's some basic information about it: OS: Windows 7 Professional 64-bit CPU: AMD Athlon 2 X2 2.8GHz (dual-core) MOBO: ASUS M4A785TD-V EVO RAM: 4GB Kingston DDR3-1066 GPU: ATI Radeon HD 4350 512MB I built this completely from scratch and I love it. I hope this doesn't sound confusing at all, but where it asks for a COM port to connect to in Qt Creator, it is looking for a USB port. Maybe I just read it wrong, I don't know. But yesterday I tried it again, but this time I plugged in my phone via USB upon booting up and I let the OS install the drivers for the device and this time it installed some serial port drivers, so I started Qt Creator and everything ran fine! It read the USB port my phone was connected to and I was able to run programs that came from the SDK on my phone which was amazing. So I'm thinking that maybe the whole problem was me not letting the OS install the necessary drivers, or something like that. I will take a look at the youtube videos for further insight into what I'm getting myself into, but thank you again for the help. I still have yet to get CODA working on my phone for on-device debugging because it looks pretty cool and fun to use, but I will once again keep you updated if I run into anything. Thank you Glad I was of some help. Sure would like to know how far you get with this. Writing new applications for mobiles devices sounds like a great idea. The world is going mobile. Desktops computers are too big for most consumer users. Like the old Grandfather Clock, they will become just collector's items. [regaining space - attachment deleted by admin]Ha ha, could you imagine if everyone had to carry around a grandfather clock and if mobile devices didn't exist?! The world would be entirely different, that's for sure. So far with my Symbian phone, I have one new app created and installed on it, but that's it for now. It is a simple GUI that lets you type in a string into a box and it adds it to another box, so it's not much for an app, but it works. It will obviously take a while to get something cool going because I still have to learn Qt's APIs first probably by reading the API documentation. I do have some pretty sweet app ideas for the FUTURE though. |
|
148. |
Solve : Calculate weight of word? |
Answer» I am trying to alphabetize by generating a weight of a word, saving those numbers, and then comparing which numbers are greater. Don't ask me why I need to do this way. Don't ask me why I need to do this way. Why do you need to do it this way? Quote from: Salmon Trout on October 12, 2011, 10:56:40 AM Why do you need to do it this way? *whispers* because its homework ?? Quote from: Linux711 on October 12, 2011, 09:48:10 AM I am trying to alphabetize by generating a weight of a word It's not really clear what the "weight" of a word is supposed to mean. Maybe if you made that clearer? Do you mean that some letters are "heavier" than others e.g. A weighs 1 unit and Z weighs 26 units? Something like that? Quote *whispers* because its homework ?? To be honest, yes, but that's only about 10% of it. The rest I already have completed. Quote It's not really clear what the "weight" of a word is supposed to mean. Ok. I'll try to be clearer. What I need is a algorithm that will take a word and return a value of that word, so that it can be put in alphabetical order. 'A' weighs whatever the ASCII value of 'A' is, etc. So I began by just adding all the ASCII values together, but that was not correct because the first character takes presidence over the rest because "aa" would come before "apple". Do you see what I mean now?It's not as simple as you seem to think it is. these are in alphabetical order a aa aaa You can't just "sort" one string. The whole essence of sorting is comparison. Quote You can't just "sort" one string. The whole essence of sorting is comparison. True, but you could generate a value based on that string, right? Quote from: Linux711 on October 12, 2011, 01:25:29 PM True, but you could generate a value based on that string, right? So what value would the string "a" have? PROBABLY 97, but I'm not sure because my algorithm doesn't work. Any help? Quote from: Linux711 on October 12, 2011, 01:53:16 PM Probably 97, but I'm not sure because my algorithm doesn't work. Any help? You are using the word algorithm incorrectly. There are sorting algorithms, sure, but like I said, you can't sort one string. Quote my algorithm doesn't work This is a great big fat clue. Quote from: Linux711 on October 12, 2011, 01:04:04 PM "aa" would come before "apple" ... and "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaa" would come before "ab". Do you see the difficulty now? MAY I but in? Think of the letters as being part of a number system from some space aliens. For this example, we shall only lower case letters from a to z. The letter am by itself, has a value of 1. the Letter z, by itself, has a value of 26. Also, the hyphen will be given a value of 0. (More of that latter). These space aliens have asymmetrical bodies with with fingers and toes that add up to 27. So they count things in groups of 27 or a power of 27. The have adopted the letters a-z and the hyphen for their number system. So in their notation: 1 = a b = 2 and so on. Now look at this: a- represents 27, but aa represents 28 and ba represents 55 also b-a represents 1459 We told you earlier the hyphen in their language represents a zero, it is a plaice holder. Myself, I can not do this in BATCH code. I would have to use VB-script. Or maybe Python. It is a form of base conversion. Using base 27 as the source. Computers don not work in base 27, so it needs to be in a common base that is used in computing. Likely a 64 bit long integer. Geek isn't getting it either. Quote from: Linux711 on October 12, 2011, 09:48:10 AM I am trying to alphabetize by generating a weight of a word, saving those numbers, and then comparing which numbers are greater.It won't work. What you are basically trying to do is generate a hash. The problem with a hash is that a collision is inevitable,especially with one so simple and comprised of so few bits. and in the case of sorting by a hash any collisions will end up sorting together. The only time I've needed to so anything remotely similar to this was when I was writing a Anagram search program that could find all anagrams of a given word from a dictionary list. Rather than a sequential search and compare, I sorted the list of words according to the sorted list of their letters; that is, the word "parent" would be sorted as "aenprt". So would "entrap". This means that all anagrams of a given word would end up being sorted contiguously. However, what you are trying to do, again, is hash the word, and then sort based on that hash. Since a hash will always lose some information, there are going to be collisions. Quote Likely a 64 bit long integer.limited to 14 characters. - I think, my math may be a bit rusty, I got that from log base 27 of 18,446,744,073,709,600,000 (~2 to the 64th power); (and it's been a while since I've dealt with logarithms). And that is for a unsigned 64-bit long, too. Doable, maybe. But as a general purpose sort algorithm? fairly useless. Especially since it can only represent the alphabetic characters and in a single case (lower case or upper case). Additionally, it doesn't give any sort of speed advantage since surely hashing (which will pretty much be what is being done) the characters into a 64-bit integer is going to be more work than simply comparing two strings, particularly since the latter case only has to compare the strings up to the point where they differ; it's a O(n+1) operation where n is the number of letters that are the same at the beginning of either string. Hashing (or converting base, or whatever you want to call it) will always be O(n) for the length of the string. Add to this the fact that VB6 (which it appears they are using) doesn't support 64-bit integers except by faking it with the scaled 64-bit integer that is the Currency TYPE, and you add a whole new meaning to the word "overcomplicated". Not to mention said 64-bit scaled integer is in fact a signed value. |
|
149. |
Solve : [Java]Using a map key as a string? |
Answer» In Java, is there any way to use a map key as a string to manipulate? |
|
150. |
Solve : Problem with vga to 3 rca cable? |
Answer» hi all, This is a component input cable. Does your television have a Component input? It will be labeled Y/Pb/Pr. Y is video, Pb is audio left and Pr is audio right. Component can not connect to standard video input.You've got this a bit mixed up. These are video only, not audio. Component Video Y carries luma (brightness or luminance) and synchronization (sync) information. Pb carries the difference between blue and luma (B − Y). Pr carries the difference between red and luma (R − Y). Composite is probably what he has on the TV, since he said: "...has 3 ports one for video and two for audio..." Quote Composite is probably what he has on the TV, since he said: "...has 3 ports one for video and two for audio..."Right. The VGA does NOT have audio on it. So the VA adapter he has is not a composite output device. I has a VGA to composite adapter and the quality is, IMHO, not worth the trouble, The device is a small box that requires power from the USB port. Nice gadget, but the image is really poor. EDIT: This COMPANY has it, but the price is high. http://mycablemart.com/ I do not have laptop i am connecting from my computer that is desktop. now let me know in details. what setting i have to change Quote from: Geek-9pm on October 25, 2011, 04:57:53 PM the image is really poor. That is because composite Video sucks, especially at higher resolutions than the NTSC standard. The best one can hope for with systems that utilize Composite is that they might also allow for the use of S-Video, which is a tad better than composite video. I use a Composite Video cable that also has a S-Video lead with my old game systems and the results are noticably better. Quote i have bought vga to 3 rca cable (this has green, blue and red wire)That is a component video cable. Quote which has 3 ports one for video and two for audio.And that is composite video/audio- Yellow for video, white and red for the two audio channels. They are not compatible, in any way, with a Component cable. Quote from: umap on October 26, 2011, 06:42:52 AM I do not have laptop i am connecting from my computer that is desktop. Go pick up and old CRT monitor, round here theyre giving them away, and people are CHARGING to get rid of them, do SOMEONE a favour and take their old one off their hands. Better picture quality For the settings, you dont have to do ANYTHING to the computer, you just need to select the right input on your TV. I recommend a CRT over one of these adapaters anyday, but its your choice. |
|