Grn Xtrm 84 Posting Pro in Training

Glad to help. Please mark the thread solved if you have no further questions. Thanks. :)

Grn Xtrm 84 Posting Pro in Training

In your if statement use

if(denom==0)

When using if statements you need to use the comparrison operator(==) not the assignment operator (=).
See if that works for you.

EDIT
Looks like sfuo beat me to it by a few seconds. LOL.

I'll also take this oppurtunity to suggest that you include prompts for the user before they enter a number.

Grn Xtrm 84 Posting Pro in Training

Sounds good :) I'll be starting piano lessons soon, expensive though. When I'm bored, I'll try something new, for example i've started getting into photography now, here are some I've taken fairly recently.

William, great pictures. I especially like the Lighting up the Path pic. They look very professional. Keep up the good work.
Also, good luck with piano. Learning an instrument takes lots of patience and practice.

Grn Xtrm 84 Posting Pro in Training

<snipped> Nevermind that was a bad post, sorry.

Grn Xtrm 84 Posting Pro in Training

Do you have all the files relating to this project saved in the same file or directory? That may be causing the problem.

Grn Xtrm 84 Posting Pro in Training

the compiler does not see the isValidStudent() as a method of Student class.

Yes I understand that. There may be a syntax error in your Student class that is causing the problem. That is why I asked to see the code for the Student class. Thanks.

Grn Xtrm 84 Posting Pro in Training

I think it would be easier for us to help if you post the Student class as well. It would help if we can see how and where your methods are defined. Thanks

Grn Xtrm 84 Posting Pro in Training

We really do want to help, but you have to show some effort before we do that. Post the code you have using code tags so we can make corrections and help guide you. We are not here to just do your homework for you.

Grn Xtrm 84 Posting Pro in Training

Scroll to the bottom of the page and click the link that says Mark As Solved (or something like that)
It will be after the last post. Thanks.

Grn Xtrm 84 Posting Pro in Training

Glad to help. Please mark the thread solved if you have no further questions. Thanks.

Grn Xtrm 84 Posting Pro in Training

Try changing line 8 to:

Scanner scan = new Scanner(System.in);
EGutierrez91 commented: thanks! +0
Grn Xtrm 84 Posting Pro in Training

I believe the first figure is supposed to be 2 triangle, one on top of the other. The second figure is supposed to be a diamond. This is the output he wants. The format got messed up because he didn't enclose the figures in code tags.

Grn Xtrm 84 Posting Pro in Training

Remove the "\n" from line 13. It worked for me this way.
\n sends output to the next line. When you are scanning input, you don't need to go to a new line.

By the way, next time you have a C question dont post it in the C++ forum. We have a forum dedicated to C. Thanks.

Grn Xtrm 84 Posting Pro in Training

No semicolons after method names in the definition.

// ------------------------------------------------------------
// Another constructor - with two parameters - if you know the name and the age of a Person
// ------------------------------------------------------------
Person(String newName, int newAge, String newNationality);
{
name = newName;
age = newAge;
nationality = newNationality;
}

Look at line 4.
Just a few small errors. It looks like you know what your doing for the most part. Good work.
By the way, to use code tags use code=java, not java=code. Thanks :)

Grn Xtrm 84 Posting Pro in Training

Where is the function definition in your code? That second snippet should be included in the first as a function definition and I'm not seeing it there. Also you didnt close your function in that second snippet.

Grn Xtrm 84 Posting Pro in Training

Can you post your revised code please?

Grn Xtrm 84 Posting Pro in Training

I don't know if this will resolve the problem but you need to put your calendar function outside of the main function. Put your function after the terminating } of the main(). See if that helps.
Also you have two braces after if/else in other spots two. If those are unnecessary, you should delete them as well.

Grn Xtrm 84 Posting Pro in Training

Do you need two braces after your if statement here

if (x==1)
{  
   {

(Lines 54 - 56)

Grn Xtrm 84 Posting Pro in Training
int a=17;
            int b=24;
            int t;
t == a;
a == b;
b == t;

It's just like that?

Well that's the right idea, but you only need to use one = sign.
You are assigning (=) not comparing (==).
Good work!

Grn Xtrm 84 Posting Pro in Training

Alright, you've suffered enough. I'll try to help you out.
To swap you need to three int values.
Let a= 1st number
Let b = 2nd number
Let t = temp holder
To swap you need to set t equal to the first number (a)
then set the first number equal to the second (b)
Finally set the second number equal to the temp value.
This way a becomes b AND b becomes a.

Grn Xtrm 84 Posting Pro in Training

The thread sounds awfully familiar...

Grn Xtrm 84 Posting Pro in Training

The code given to you by firstPerson makes the user input a new number while the current value (input of the variable) is less than zero. This repeats until the user enters a valid number.

Grn Xtrm 84 Posting Pro in Training

I just gave some parts to help the OP get started. He needs to figure out how to use if statements to check illegal inputs and how to find the smallest number in the array. At the very least I introduced topics such as arrays that the OP can do further research to learn more about. Sorry if the post was bad.

BestJewSinceJC commented: Nevermind, it was a misunderstanding. +4
Grn Xtrm 84 Posting Pro in Training

A c++ program to solve your problem can be done very simply.
First declare an array of size 10

int a[10];

then use a for loop to obtain a number for each of the 10 positions of the array.

for(int i = 1; i<=10; i++)
    {
            cout<<"enter number "<< i<<endl;
            cin>>a[i];
    }

Finally add all of the elements in the array by using the plus operator.

int sum=a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10];
     cout<<"sum = "<<sum;

This is an easy way to solve your problem.

Grn Xtrm 84 Posting Pro in Training

PDL is program design language. It involves no actual coding just writing words that describe what you want a program to do. This is pretty much what you did in your first post. Theb you take the words and turn it into computer code. I take it this is where you are stuck.

Grn Xtrm 84 Posting Pro in Training

it says using a PDL of your choice

And what is your choice? :)
My personal favorite language is C++.

for(int i=1; i<=10; i++)

Have you ever learned about something called an array?
That could be used to store the 10 values, but if you've never learned arrays then there is a less effiecient way to solve your problem.

Grn Xtrm 84 Posting Pro in Training

i don't know how to start a loop or write an algorithm how do you write this?

If your not using a specific programming language and just want psuedocode, my previous post should be ok for you. Well the loop part at any rate.

Grn Xtrm 84 Posting Pro in Training

A for loop will allow you to have a user enter the ten numbers

for(variable=1 to variable is less than or equal to 10, then increment the variable)
//In the body of the loop you will ask the users to enter the numbers

Did you have a specific programming language in mind?

Grn Xtrm 84 Posting Pro in Training

Glad I could be of some help. Please mark the thread solved if you have no further questions.
Thanks.

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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! :)

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

Your last few functions have semicolons after the function name. Get rid of 'em.
Guess I missed that too, originally. ;)

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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. :)

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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.

Grn Xtrm 84 Posting Pro in Training

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 :)

Grn Xtrm 84 Posting Pro in Training

The top of the stack is -1 when the stack is empty. When you fill it using push(), the top will change. A return value of -1 lets the user know that the stack is empty.

Grn Xtrm 84 Posting Pro in Training

I coded for my object oriented design with Java final today. :S Mostly dealt with objects from the Collection heirarchy. I think I did pretty well.:)

Grn Xtrm 84 Posting Pro in Training

You can achieve that by using a table with three rows. Set the top and bottom rows height to 10% and make the middle row 80%. However, this doesn't use divs and it looks like you want to. Sorry if this post is totally useless to you.

Grn Xtrm 84 Posting Pro in Training

Do you have a mystack.h file implemented in the same folder as your main program?

Grn Xtrm 84 Posting Pro in Training

I'm currently learning from a book called Data Structures Using Java 5.0 by Nicholas J. DeLillo. It's a great book with lots of great examples.