Grn Xtrm 84 Posting Pro in Training

If you have not leaned c++ there is obviously no way you can do this problem. When you start to learn the basics of c++ the solution to this problem will become quite easy to achieve. Don't get ahead of yourself. If you know nothing about c++, don't expect to be able to write programs in c++. Wait until you learn c++ to tackle this problem.

Grn Xtrm 84 Posting Pro in Training

Hey nice code. To add it as a code snippet start a new thread and click the drop down arrow that appears on top. From there select code snippet.

Grn Xtrm 84 Posting Pro in Training

Once you fill the array, loop though each element of the array and use a simple cout statement to output the element.

Grn Xtrm 84 Posting Pro in Training

I made the game of Nim, followed by battleships, then chess. Then i worked on some card games (Pontoon and poker).

I also made a blackjack game in javascript and a basic number guessing game using c++.

Grn Xtrm 84 Posting Pro in Training

Do you have the displayMatrix function defined anywhere? I dont believe it is a built in function. Supply us with the code for the displayMatrix function so we can see if there is a problem.

Grn Xtrm 84 Posting Pro in Training

Everything seems to be back to normal, for now. :)
Good work resolving the problem Dani. I know you've been working really hard lately.

Grn Xtrm 84 Posting Pro in Training

Im gonna take this thread in a slightly different direction and talk about the first game I made. It was a version of "Rock, Paper, Scissors" using javascript. Just a simple school assignment for my web programming class a couple of years ago. I'd like to hear the first game made by the rest of the community members.

Grn Xtrm 84 Posting Pro in Training

Try changing int x to double x and change line 9 to:

double s = x * num;

When you declare power as double, that means the return value must be also be double.

Grn Xtrm 84 Posting Pro in Training

The array isnt being output because you dont include that line in your program. You have to print the array when your done filling it.
To use code tags click the code button above the box in which you type your reply.

Grn Xtrm 84 Posting Pro in Training

When you call the function in main(), the two parameters should be the base and the exponent. In you last post these would refer to u and v.

power(u,v);
Grn Xtrm 84 Posting Pro in Training

1. 1/3 * 3 is equal to 1. Is that what your program is telling you?
2. Accept user input of numbers to represent x and y. Then apply them to the formulas.

double x, y, product, expression2;
product = 3*x;
expression2 = product + y;

Not sure if this is exactly what you are looking for. The original post was quite vague.

Grn Xtrm 84 Posting Pro in Training

The same thing happened to me in the C++ forum. I have been experiencing problems regarding time of posts all day today. For example sometimes it shows the date instead of the how many minutes, hours, days, ect ago the post was made. Also I have not been recieving email updates when a thread I have subscribed to has be replied to. I hope these problems are being addressed and will be resolved soon.

It just happened again . lol

Grn Xtrm 84 Posting Pro in Training

How did my post get above the OP? And why does it say 1 hour ago when I posted a few minutes ago?
Daniweb sure has been acting strange lately ;)

Grn Xtrm 84 Posting Pro in Training

In this assignment, we will develop a simple inventory database program (database application) for
a small computer store.
No you will.
You cant just post your homework assignment and expect to get a quick answer. There is no instant gratification on Daniweb. You must show effort and we will try to help you work through your problems.

Grn Xtrm 84 Posting Pro in Training

Im using the following code and it compiles fine

#include <iostream>
using namespace std;
int main()
{
int max1, max2, min1, min2, poscount, negcount, num;
double sumpos, sumneg, avgpos, avgneg;  

while (num != 0) 
{ 
 cin >> num;  
 if (num < -100 || num > 100)
    {
         cout << "Enter number again"<<endl;
    }
 else if(num !=0)
     {
         cout<<"enter another number"<<endl;
     }
}
   
   char wait;
   cout<<"enter any key to exit"<<endl;
   cin>>wait;
return 0;
}
Grn Xtrm 84 Posting Pro in Training

Can you post the new code please. I cant see whatever line 2 is in your program and therefore cant resolve the problem.

Grn Xtrm 84 Posting Pro in Training

Well its a start, but your current code has several errors.
Line 6 will give you errors because num1 has not been declared. You should change it to num and declare it before the loop. Also you must use

while(num!=0)

You want the loop to continue until the user enters 0.
Lines 7, 8, and 9 are not needed as they are just redeclarations of variables.
Compare your code with mine and see if you can understand your mistakes. You need and if/else instead of another while loop. You want to test the values. If they are not valid you print an error. If they are valid, you ask for another entry.

int num;
while (num != 0) 
{ 
 cin >> num;  
 if (num < -100 || num > 100)
 {
         cout << "Enter number again\n"<<endl;
 }
 else
     {
         cout<<"enter another number"<<endl;
     }
}

However, if you want to use the number when after entry, you should consider using an array. This way, you store all the values in the array and can test which value is smallest, largest, etc.

Grn Xtrm 84 Posting Pro in Training

If you have two parameters in your function definition then you need to have two parameters in the function call. Make sure the parameters in the function call are of the same type data type as those in the definitiion.

Grn Xtrm 84 Posting Pro in Training

As the built in function is declared, the power function should contain 2 parameters, the first being the base and the second being the exponent. Try writing the function with a declaration like this:

double power(double x, int n)
Grn Xtrm 84 Posting Pro in Training

Sorry about your parents but they really do care about you and make decisions that they believe are in your best interest. Although I don't consider sex to be a delinquent act, sknake is right in that you should obey your parents' wishes and try to make them proud. Eventually they will let you be you. I went through a similar experience during my teen years. You'll get your independence soon enough. ;)

Grn Xtrm 84 Posting Pro in Training

If you declare the function as int then you must return an int value in the function definition.
By the way, I'm not sure if you are aware but there is a built in power function in the math library.
See this for more info
http://www.thinkage.ca/english/gcos/expl/c/lib/pow.html

Grn Xtrm 84 Posting Pro in Training

Maybe you should try paying attention and try to learn the material. Instead of arguing over pointless matters, listen to your teacher and try to learn something. Believe it or not, there are people in the world who know things that you do not.
By the way, maybe you should practice what you preach and try not being mean to the people who are trying to help you. And I'm not coming out of the woodwork I'm on this site almost everyday. I like helping people who aren't arrogant jerks. So maybe you should just sign off now...

Grn Xtrm 84 Posting Pro in Training

You need a main() that will put all the functions to use. Call the functions in main(). Start it with:

int main()
{
//call functions and write other code
return 0;
} // closes main
Grn Xtrm 84 Posting Pro in Training

Shouldnt you be in class now? Cutting class isnt gonna help your already self proclaimed poor java skills.

Grn Xtrm 84 Posting Pro in Training

He wasn't being rude, he was just telling it like it is. You should grateful that he told exactly how to do the problem, not mad that he made a comment about your major. Follow his "angry ordered list" and you should be able to solve your problem. Also, next time you have an assignment, don't wait until the day its due to start asking for help.

BestJewSinceJC commented: Thank God for computer majors. :) +4
Grn Xtrm 84 Posting Pro in Training

This code snippet may help you.
http://www.daniweb.com/code/snippet217345.html
Its written in C but you should be able to see what us being done. You should always search the forums before you have start a new thread. You may just find your answer there.

Grn Xtrm 84 Posting Pro in Training

ok thanks a lot for all your help I get it now. In my class the teacher just lectures and we don't program at all that is for hw!!!!

Glad I can be of help.
If you have no further questions please mark the thread solved.
If you have more questions, ask. :)
Thanks.

Grn Xtrm 84 Posting Pro in Training

Sorry about that lol. and sorry if this seems basic but how do i ask the user to input the number from 1-30 but it can only be a number from 1-5

The while loop makes the process repeat 5 times.
To ask the user to enter a number use:

cout<<"enter a number between 1 and 30 inclusive"<<endl;

To accept the input use

cin>>number;

Obviously number must be declared as an int value. This same variable will be used in the for loop, so make sure they are the same. You'll also want to use an if statement to make sure the number input is actually between 1 and 30.

Also include this line before int main()

using namespace std;

I'm not sure if that was in your original code.

Grn Xtrm 84 Posting Pro in Training

Do you think you can show me a completed copy of the code source that would help me visualize it better.

LOL, nice try. "Help me visualize it better"--That's a new one. ;)
You need to follow exactly what I said in my previous post.
Start your while loop.
Ask for and accept user input.
Begin for loop to print the number of asterisks. The number of asterisks will be as many as the number entered by the user.
Close for loop
Increment x by 1 using x++
Close while loop

So in essence, the for loop will be enclosed in the while loop.

Thats it. Give it another shot, you'll get it.

Grn Xtrm 84 Posting Pro in Training

Ok, your original post says you want to read in 5 numbers so you'll want to use this as the condition in the while loop:

int x=1;
while(x<6)
{
//prompt to enter number
//accept user input

Next you'll want to use a for loop to actually display the asterisks

for(int i=1; i<=num; i++)
    {
            cout<<'*';
    }        
    cout<<endl;

Finally you want to increment the value of x and close the while loop.
Try to understand that and let me know if you have any questions.

**EDIT**
You will also need to include an error check to make sure the values are between 1 and 30. Use an if statement.

Grn Xtrm 84 Posting Pro in Training

Show us what you did so far then we will be glad to make corrections and suggestions.
As a preview, I think you will want to use a for loop nested in a while loop. We'll get into the specifics when you post your code.

Grn Xtrm 84 Posting Pro in Training

If you've ever seen shows like "A Haunting" on discovery channel, you know that spirits/ghosts are quite different than living human beings. In one episode, a ghost made a guy have homicidal thoughts about his wife. And another time, a ghost "scratched" a guy and he had huge marks all over his body. Sorry for the mini-rant but its a very entertaining show, whether you believe in ghosts or not. :)

Grn Xtrm 84 Posting Pro in Training

I dont believe that you would get an assignment in c++ if you never had a class relating to it. Show some effort and we will try to help you. Also, try searching the forums for this question, it seems to show up quite a bit. In the future you may want to pay attention in class and try to learn something,

Grn Xtrm 84 Posting Pro in Training

Use a for loop, it's quite simple really.

Grn Xtrm 84 Posting Pro in Training

Here's how I would start

#include<iostream>
using namespace std;
int main()
{
//write code
}

But seriously, try something and show us what you did.

Grn Xtrm 84 Posting Pro in Training

i posted it there also

Well you should only post it there. This forum is for help with c++.

Grn Xtrm 84 Posting Pro in Training

You'd probably get more help if you posted this question in the appropriate hardware forum.

Grn Xtrm 84 Posting Pro in Training

You can use a series of if statements to test the input of the number of books. Depending on the input, the different if statements execute. Each statement will produce a different discount.

Grn Xtrm 84 Posting Pro in Training

Extract each digit from the input value and use a switch statement to output the correct letters.

Grn Xtrm 84 Posting Pro in Training

Why would you need to accept and integer if you are just going to do the factorial of 10? Anyway, this is a very common beginning recursion problem. If you search the forums or the internet I have little doubt that you will find your answer along with an explanation in no time.

Grn Xtrm 84 Posting Pro in Training

You need to put semicolons after the statements in the if/else statements. (i.e. you need semicolons after the increment statements.)

Grn Xtrm 84 Posting Pro in Training

I know that like the rep points, anyone can give you whatever points they want, negative or positive, but I find it strange that someone decided to down vote a post that is 1 year old without a single explanation.
At least with the reputation system you get to describe the reasons for your selection.

Yeah but then there are the people who give you negative rep because they don't like your signature. :icon_rolleyes:
http://www.daniweb.com/forums/post1024213.html#post1024213
Not that I'm complaining or anything ;)

Grn Xtrm 84 Posting Pro in Training

Initializing the variable means giving it a value. Declaring a variable means to create (i.e. it exists)
As for your questions, look at the code. ;) If the variable hasn't been given a value, then it has not been initialized, it has only been declared.

Grn Xtrm 84 Posting Pro in Training

In the Java programming language, every application must contain a main method whose signature is:

public static void main(String[] args)

Taken from http://java.sun.com/docs/books/tutorial/getStarted/application/index.html
Your main method violates this.

Grn Xtrm 84 Posting Pro in Training

In your while loop you will need to include a counter for both odd and even numbers. Also inclyde the if else statement in the while loop. For example:

while(number != 0)
{
//ask for and accept the number from the user
if(number%2==0)
//increment even counter
else
//increment odd counter

}

The only thing you need to change in the while loop is to make 0 an integer not a character with quotes. This is what Ancient Dragon was trying to point out to you.

Grn Xtrm 84 Posting Pro in Training

The formula for calculating the area of a circle is pi*(radius*radius).
You can declare pi as a const double and set it equal to 3.14. So you need to have a variable for radius. Then simply put all the values into the formula.
Also use code tags when posting code.

Grn Xtrm 84 Posting Pro in Training

how to program a program to calculate the area and the perimetre of a circle?
pls answer me asap i need to know quickly
thank you!

Then you better start showing some effort ASAP. Post your code and any problems you are facing.

Grn Xtrm 84 Posting Pro in Training

Test if the number is even or odd using the modulus operator.
If the number % 2 equals 0, then the number is even.
If the number % 2 equals 1, then the number is odd.

Grn Xtrm 84 Posting Pro in Training

Post your question in the appropriate language forum and people will help you with it.

I think he missed the due date on that assignment. ;)

Grn Xtrm 84 Posting Pro in Training

In your first for loop you should be printing the students in course 1. I'd change line 42 to

System.out.println("Num of student in course1:"+course1.getnumberOfStudents());

Then your second for loop would be the same only replacing 1's with 2's.

Also I am assuming that your methods are defined somewhere in a separate file. Am I right in assuming this?