I had Python in high school, it is a nice language for beginners.
I wish I had a programming class in high school.
I was so unprepared for college programming. :(
But I guess I picked it up pretty quickly. :)
I had Python in high school, it is a nice language for beginners.
I wish I had a programming class in high school.
I was so unprepared for college programming. :(
But I guess I picked it up pretty quickly. :)
Glad I could be of some help. Please mark the thread solved if you have no further questions.
Thanks.
I would accomplish this by adding each element (i.e. xcomputers) to an array. Then I would use a for loop and switch statement to output the number associated with each character. The for loop would iterate through the array and apply each letter to the ensuing switch statement, which then outputs the correct number.
As for your second question involving lowercase, I did the following and the code ran fine:
if (sa == "NC" || "nc")
sa = NC;
else if (sa == "SC" || sa == "sc")
sa = SC;
else if (sa == "GA" || sa == "ga")
sa = GA;
else if (sa == "FL" || sa == "fl")
sa = FL;
else if (sa == "AL" || sa == "al")
sa = AL;
You were on the right track. Extra parentheses are not needed.
I was able to run your code successfully by using:
bool err = false; //User enters NA State Abbreviation
cout << "Enter one of the following State Abbreviations for full name:" << endl;
cout << "NC, SC, GA, FL, or AL. ";
cin >> sa;
if (sa == "NC")
sa = NC;
else if (sa == "SC")
sa = SC;
else if (sa == "GA")
sa = GA;
else if (sa == "FL")
sa = FL;
else if (sa == "AL")
sa = AL;
else
err = true; //Wrong entry
if (err)
cout << "You have entered an Invalid State Abbreviation" << endl;
else
cout << "The State Abbreviation you entered stands for " << sa << endl;
Start the error as false until you recieve an invalid input, then make it true and output the message.
2. Write a function that reverses a string by making use of a stack. Your function could push elements on the stack one by one, and then build up the result by popping them off the stack.
Use the push function to add each element of the string onto the stack, then use the pop function to remove each element. You can print each value after popping, then move onto the next element until the stack is empty.
like to know more about IronPython that feeds into C#.
First of all, That's what she said. :)
But seriously, I'd like to know more about python. I touched on it very breifly in my first semester of college but never came back to it. The class was an intro to programming class, so pretty much all we did was learn about loops and other very basic stuff. :D
He asked for a book to learn, not for 170+ lines of code that he will have no idea how to use. He is trying to learn. Your code does absolutely nothing to help a beginner understand how vectors actually work.
@OP follow Ancient Dragon's link for help with vectors. :)
When using a vending machine you insert your currency into slots in the machine. Then you select the desired item using buttons on the machine. In return you will recieve the desired item and change if you overpaid for the item. :)
In case you can't tell I have no idea what your actual question is. ;)
Just thought I'd go off on a little tangent to portray my cynicism towards those who ask strange questions on this site.
That was their best period. I loved the white album.
Yes, so many great songs, so little time to learn them all. :)
I can already play a few of their earlier songs including I Saw Her Standing There. Great bass line by Sir Paul McCartney. But yeah, 67-70 was a great period for the Beatles.
I just purchased a bass tab book of Beatles songs from 1967-1970. I can't wait to learn some of these classic songs. First up is "Here Comes the Sun".
Hi Irene welcome to Daniweb. I live pretty close to you (Pelham Bay in the Bronx) :)
I can see by the two links you posted that you are a very good web designer.
Enjoy your time here and keep up the good work!
i want to start from a book........
can you tell me writer and book.....
plz refer the easiest book having most exercises of pseudo codes.
thanks
The point of psuedo code is to help a programmer follow a guideline when writing computer code.
You should decide what language you want to learn (I recommend c++) and get a beginner book for that specific language. You can develop psuedo code when you have an idea for a program that you want to write.
If you don't show that you have actually tried by posting your code, no one in this community is going to help you. We can't debug your program and help you with errors if you don't show us what to help you with.
EDIT:
Looks like Tom Gunn is one step ahead of me, as always! :)
A shergold (vintage 70s/80s english)
Ah, very nice.
Take a look at this monster Shergold.
http://www.estroband.it/Shergold.jpg
Electric Bass Guitar (4 string)
Cool. If you read the previous posts you'll recall that I play bass too. I have an Ibanez SD-GR (pretty cheap), which you can see on my profile page. However, I really want to buy a Hofner. What kind of bass do you play?
The way I stop the processing is by adding:
char wait;
cout<<"Enter any key to exit";
cin>>wait;
You can put this code anywhere in the program so you can view the output at your own pace.
Oh, okay, I see the problem there! I took out those semicolons and it compiles fine now. Thank you guys for the help!! :)
No problem, glad to help. :)
Can you please click "Mark as solved" at the bottom of the page if you have no further questions.
Thanks.
Your last few functions have semicolons after the function name. Get rid of 'em.
Guess I missed that too, originally. ;)
In CPU.cpp, remove
public
from all of the method definitions. C++ does not work like Java and C#, where the access level is applied to each entity.
Wow! How did I miss that one. ;)
Another good call Tom Gunn. :)
@OP read Tom Gunn's response.
When I create classes in c++ I include the header and all of the functions, constructors, etc in the same file. I'd call it CPU.cpp.
Then I create a new file with the main method with the following line:
#include "CPU.cpp"
Not sure if that is neccesary but maybe worth a shot.
@ Tom Gunn
You are right that they are bad examples. :)
The only reason I suggested a factorial function is because it was what I did when I first learned about recursion, and Rabex is obviously new to the topic. I also wrote a function involving the fibonacci number sequence.
A function to calculate factorials in math is a common example of recursion. The function calls itself until it reaches its "base case", which in the factorial example is n=0.
It is possible without using a string. The coding will not be that hard.
Don't you think using a string is easier than an array, or is that just me?:?:
Not that arrays are exactly rocket science. :)
I revided the code to make it more efficient.
This version includes if/else statements to output specific messages based on user input:
while (name != "stop" )
{
cout<<"Enter your friend's name (""stop"" to quit): ";
cin>>name;
if(name != "stop")
counter++;
}
if (counter>0)
cout<<"so you have "<<counter <<" friends"<<endl;
else
cout<<"go make some friends loser"<<endl;
As you can see this new code outputs counter NOT counter-1 because I have included it in an if statement. This code is much better than my first attempt.
Let me know if you have any questions about this code.
You have a few problems with your code.
I made some changes and got it to work.
First, I made name a string value instead of a char.
I also changed to while loop to:
while (name != "stop" )
{
cout<<"Enter your friend's name (""stop"" to quit): ";
cin>>name;
counter++;
}
What this does is increment counter when a name is added.
This includes the name "stop" so when you output the total number of friends you must use counter-1.
Let me know if you have any questions about this.
Create your variables and use cout statements to ask the user for the values of each variable. Then use cin>> to accept the user input for each variable.
Post the code you have written so far, so the community will be more willing to help you.
This has been solved thanks to the help I received!
LOL. Thats not what I meant. Go to the bottom of the page with the last post and click the link that says Mark as solved (or something to that affect.)
Thanks again G. :)
The first for loop accepts the user input integers and adds them to the vector. The second for loop adds up the number of individual integers in the vector.
@ johnvitc
Maybe you should test out your new skill on this thread :)
No problem, that's what we are here for.
Also, please mark the thread as solved if your are satisfied with your answer.
Why don't you look at this to get started:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html
You will need to use output and input
cout<<....;
cin>>....;
and also if statements to check if the user entered the correct answer.
if( //user input == correct answer)
cout<<"correct";
else
cout<<"wrong";
I hope that can get you started in the right direction.
Indentation is not an issue in Java. Just keep all your previous code inside the braces {}.
By the way, you can delete the line
else if(choice == 0);
The while loop replaces this.
Try wrapping your if and else if statements in a while loop.
while(choice != 0)
{
if...
else if...
else...
}
This should stop processing when the user enters 0.
Please mark the thread as solved if you don't need any further help, so people can pass over it instead of wasting there time with an already answered question.
Thanks.
Thats much clearer. Thanks.
I would user the scanner object to obtain user input and then apply that number to the size of the array.
use:
Scanner input = new Scanner(System.in);
int number = input.nextInt();
The number input by the user will be stored in the variable 'number'.
lines 23 and 28
I think Ancient Dragon meant to say lines 23 and 27. :)
Don't put semicolons after if and else.
System.out.println("Would you like to enter a random number " + "manually or accept the default of 6?" );
I don't understand this part of your code. How do you expect the user to enter random values? Do you want the user to input values that he makes up or do want the computer to randomly generate numbers? Can you please clarify this.
Or use daniweb search:
http://www.daniweb.com/forums/search.php
Oh. Thanks I never new about that. :confused:
I think the new design is fine. I think it would be cool if we can filter posts by forum. For example: if I want to see all the posts I contributed to the Java forum I can filter all my posts by "Java". I'm in no way trying to burden Dani with extra work. It's not really important, I just thought it would be cool...unless this feature already exists and I just can find it :)
Thanks very much. This is my first post so will be more cognisant of the tags. I will play a bit more and see what I can come up with.
Ok. Feel free to ask any questions you encounter along the way.
Good luck!
Ask the user if he wants to fill the array manually or automatically using:
System.out.println("Would you like to enter manually of automatically?")
Then use if statements to generate the different results.
For example:
if(//user input == manually)
//use a for loop to accept values up to the size of the array
if( //user input == auto)
//fill the array as you normally would
I hope this is of some help to you.
By the way, as the first person to reply to this thread I feel it is my duty to tell you to use code tags when supplying us with code.
Thanks and good luck.
The runtime environment initializes argc before calling main(). The code will work, but it will print the arguments in order, not in reverse order.
Whoops. Sorry I never saw that argc before. I thought that was the name of his variable.:confused:
Sorry for the bad post. :'(
Declare a new array called Z[20].
Then use the following code to add the corresponding numbers.
for (int count = 0; count < 20; count++)
{
Z[count]=X[count]+Y[count];
cout<<Z[count]<<endl;
}
This code says:
Take the values at position 'count' of arrays X and Y and add them together. Then place that value into position 'count' of array Z.
Follow the previous post to learn about square roots.
#include <iostream> using namespace std; int main(int argc, char* argv[]) { for(int i = 0; i < argc; i++) cout << "argv[" << i << "] = " << argv[i] << endl; return 0; }
Now all I need to know is the correct way to write a reverse for loop that will start with arv, print it, add a space and then print argv[i-1], space etc... until we get to argv[1].
This code won't work because your stopping condition (argc) has not been given an initial value. Also, if you want to print in reverse order you'll probably need to use i--.
My personal favorite is
58 1964 British rock group The Beatles takes the U.S. by storm after debut on the Ed Sullivan Show
I love the Beatles. (especially Paul McCartney's Hofner bass :) )
lol, I am pro-choice when it comes to smoking. As long as they don't harm others while doing it (thank the smoking ban!).
Once again not to get off your original topic:
I don't care if people smoke either. I just don't understand why anyone would if the hazards have been known since 1964.
(See, I related it to top 100 link :) )
Number 100 makes me laugh. The warnings have been around for so long, yet people still smoke for some reason. What a crazy world we live in! I want to know why so many people out there risk there lives for such a pointless and easily avoidable reason.
By the way, sorry to get off topic. I know majestic0110 never intended to create an anti smoking thread.
Please mark the thread as solved if your question has been answered. This way the other members of the community don't waste their time reading an already answered question.
Thanks.