Grn Xtrm 84 Posting Pro in Training

I think in the Nation function, you are trying to give values to some of your variables. If this is indeed the case, you are assigning values in the wrong manner.

You need to use variableName = value; to accomplish this

name = lname;
land = 20;
// etc .........

Hope that helps a bit.

Grn Xtrm 84 Posting Pro in Training

The lines ranging from 26 to 50 should be enclosed in a while loop that keeps running until the user guess = the random number.

Grn Xtrm 84 Posting Pro in Training

No problem, glad to help :)

Grn Xtrm 84 Posting Pro in Training

You just need to change your 2 inner while loops to if/else statements.

if( number % 2 == 0 )

on line 15
AND

else

on line 20

Good job, you're almost there.

Grn Xtrm 84 Posting Pro in Training

How about instead of using E to exit you use an integer like -1. This way you don't have to mess around with strings and parsing integers and equals methods. Why make things harder than they need to be? ;)

Grn Xtrm 84 Posting Pro in Training

Maybe I'm misinterpreting the problem, but don't you want the user's input to be a number? If so, change the userInput variable to an int, and use that as the test in the if statements. The scanner will use the function nextInt();
Good luck, you're getting there.

Grn Xtrm 84 Posting Pro in Training

The data type on your variable seems wrong to me. The input should be an integer (i.e. the number grade). The way you do your scanner input would also change along with the data type.
Good luck.

Grn Xtrm 84 Posting Pro in Training

You have most of the code written to solve your problem already. You just need to put it in the right spot.
Re-write your division case as follows:

case '/': answerd = Numbera / Numberb;
if (Numberb == 0 )
{
            cout << "ERROR Cannot divide by 0" << endl;
            break;
}
cout << answerd << endl;
break;

This way the answer will never be output if the second number is 0 and the operator is division.
Also, you don't need anything after the switch statement besides the system pause. Hope that helps.

To use code tags, press the code button when you want to post code. Dani really can't make it any easier than it is now. ;)

Grn Xtrm 84 Posting Pro in Training

Hi again,
First of all, your code is really messy. You can't write functions inside of main. You should write your function after main concludes. Also your function needs to be enclosed in braces{ }. Finally, you need to provide a function prototype before main.
Your code should look something like:

#include<iostream>
using namespace std;
int sumTo( int x, int y); //function prototype
int main()
{
    int a,b;
    cout<<"please input two integers " <<endl;
    cin >> a >> b;
    int sum = sumTo(a,b); //call the function
    cout<<sum;
    

return 0;

}//end main

int sumTo(int x, int y)
{
   //write code for the function here
    return sum;
}//end function

You are making progress. Keep it up and good luck.

Grn Xtrm 84 Posting Pro in Training

Just use an if statement to test which number is larger.

if(x <= y)
    {
        for (int i = x; i<=y; i++)
        {
            sum+=i;
        }
        cout<<sum;
    }
    else
    {
        for (int i = y; i<=x; i++)
        {
            sum+=i;
        }
        cout<<sum;
    }

Notice the difference in the two for loops. That should be of great help to you.
Please note that this is definitely not the most efficient way to test. But for such a small program, it will suffice.
Remember to declare your variables!!

Grn Xtrm 84 Posting Pro in Training

You are very much on the right track. But have a few problems that are holding you back.
First, you can't use variables that haven't been declared with an appropriate data type. You've done that with high, low, and sum.
Low and high can be replaced by the x and y values respectively, as long as you ensure that the first number entered is smaller than the second. Also you need to declare sum and output its value outside of the loop.
Good luck.

Edit: You also want to include the high value when iterating through the for loop. So you'll need to use less than or equal.

Grn Xtrm 84 Posting Pro in Training

In my opinion, it would be much easier to think of the each name as separate character arrays. Take each name in separately and print the 0th element of each.

#include <iostream>
#define MAX 20
using namespace std;

int main()
{
    char first[MAX];
    char last[MAX];
    char mid[MAX];
    
    cout<<"enter first name"<<endl;
    cin>>first;
    cout<<first[0];

     return 0;
}

That should be able to get you on the right track.

EDIT: If you need to use the get and ignore functions, sorry to have wasted both of our time.

Grn Xtrm 84 Posting Pro in Training

Just add a while loop at the beginning of the code and close it at the end. This is a simple way to allow repetition of a program.

char again='y';
    while(again == 'y')
    {   //execute the program

cout<<"Would you like to run again?"<<endl;
        cin>>again;
        }//close while loop
Grn Xtrm 84 Posting Pro in Training

I'll give you a hint to what I'd do.
Use a for loop to iterate through the array
Use an if statement to check if the number is greater than 1.
You'll need to include a counter which you will increment every time the if statement is successful.
This is not a very difficult problem. Use my advice and post back with your best effort. Good luck.

Grn Xtrm 84 Posting Pro in Training

You have a ton of easily resolvable errors in your class.
1. class and while must be lowercase ( you have them starting with a capital letter)
2. You're missing semicolons after

void setday(int d)	
{day = d}

and I'm not sure what you are trying to accomplish with those curly braces.
3. You are trying to set the integer variable 'day' to a non integer value 'd'. You must have 'd' declared as an integer as well and you'll want to give it a value.
4. It looks like your trying to use array values in the function. You need to use square brackets [] not parentheses.

Start with these problems and try again. Good luck. :)

Grn Xtrm 84 Posting Pro in Training

In the for loop, check the condition. You say int<=b; when you really mean i<=b;
Sorry Fbody, I missed your last post. :)

Grn Xtrm 84 Posting Pro in Training

Maybe my eyes are decieving me, but it looks like you just need to add another curly brace at the end of your main method. It seems to me that the while loop started on line 22 never gets closed.

Grn Xtrm 84 Posting Pro in Training

The verses can be done very easily using a for loop.

int bottles;
    //have user enter number of bottles and store it in the 
    //bottles  variable
    for(int i=bottles; i>=1; i--)
    {
          //print the verses using i for the current amount of bottles
          // and use i-1 for the remaining bottles
     }

When the loop variable i reaches 1, it will stop because the bottles remaining will reach 0.

Grn Xtrm 84 Posting Pro in Training

After resolving that first problem I realized that your code was still not working correctly. I made some adjustments to the code and made it much simpler.
You should be able to use this code to fit your needs. i.e you can add your if statements to check for errors in input. The following will allow you to correctly find the average.

import java.util.*;

public class test_score
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int num_of_scores,sum,count;
		int[]score=new int[100];
		sum=0;
		count=0;
		System.out.print("Number of test scores = ");
		num_of_scores=input.nextInt();

		for(count=0; count<num_of_scores; count++)
		{
			System.out.print("Enter the scores ");
			score[count]=input.nextInt();
			sum += score[count];
		}

		System.out.print("Avg = " + sum/num_of_scores);
	}
}

The algorithm you were using to find the average was incorrect. All you need to do is add all of the test scores together and divide that sum by the total number of scores.
Also you should use double values instead of ints because the average can often times result in a floating point number.

Grn Xtrm 84 Posting Pro in Training

Remove the semicolons after the if statements. If statements followed by semicolons will not result in compile errors, but will mess up the output of the program.

Grn Xtrm 84 Posting Pro in Training

You need to use == when doing if statements. You are suppose to compare(==) not assign(=) in if statements.

EDIT:
A few seconds too late i suppose ;)

Grn Xtrm 84 Posting Pro in Training

Everyone would be glad to help if you show some individual effort. If you have a question, feel free to ask it, that's the whole point of this forum after all.

Grn Xtrm 84 Posting Pro in Training

We'd all be glad to help you if you provide us with the code you tried to write and show us what your having trouble with. Try something yourself first, and then ask us for assistance if/when you encounter a problem. Good luck.

Grn Xtrm 84 Posting Pro in Training

This line is probably giving you trouble

char replyChar=;

What are you trying to do here?

EDIT
Follow the next post. AndreiDMS gives a good solution to your problem.

Grn Xtrm 84 Posting Pro in Training

Many apologies to the OP, I missed the brackets for the check array in the if statement. Thanks to Dave for pointing out the mistakes.

Grn Xtrm 84 Posting Pro in Training

I noticed a few problems in your edit. First of all, remove the semicolon from the if statement. That is undoubtedly throughing off your output. The only other change that seems to be necessary is to test if check is NOT EQUAL to "\n". The following code produced the correct output when I ran it.

int count = 0;
  char check[81];
  char temp[81];
  while (fgets(temp, sizeof(temp), fptr) != NULL)
  {
    fscanf(fptr, "%s", &check);
    if (check != "\n")
    {
      count++;
    }
  }

  printf("%d\n", count);

My text file looked like this:
Panic Attack

Dream Theater

Progressive Rock
Great Band!

The output was 4.

Grn Xtrm 84 Posting Pro in Training

Try rewriting the while loop like this:

while ( fgets ( temp, sizeof temp, fptr ) != NULL )

Increment the counter inside the while loop as you have correctly done. Then output the result after the loop.
This is how I have done it successfully in the past. I'm sure there are other ways to do it as well. This is just what I have been able to come up with during my time with C. Good luck!

Grn Xtrm 84 Posting Pro in Training

Like A Movie by Midtown. Great pop punk song and the first cover of my new duo side project. :)

Grn Xtrm 84 Posting Pro in Training

That is Wal-Mart this year -- no Christmas music and no Christmas tree at the front doors. Its really sad that Wal-Mart isn't in the Christmas spirit this year.

Sadly, Christmas is no longer politically correct in the United States. Must be fair to the people who don't celebrate Christmas. Although I don't know how someone gets offended by a tree with lights and decorations porttraying an obese man in a red costume, but that's the way the world is today.

Grn Xtrm 84 Posting Pro in Training

Show us what you tried, so we can make corrections and give you some suggestions on how to improve your code.

Grn Xtrm 84 Posting Pro in Training

Let me see if understand your problem correctly. You want to keep running the program until the user enters 5 at the menu to quit. Is that right? If that is indeed what you want to do, just include a while loop around your menu function.

while( x!=5)
{
cout<<"Hello! Let's play a math game. Please choose one of the 5 below.\n\n";
cout<<" 1) Add\n 2) Subtract\n 3) Multiply\n 4) Divide\n 5) Quit\n\n";
cout<<"Press 1, 2, 3, 4. Have fun!\n\n";
cout<<"If you'd rather not play my math game, press 5. Jerk.\n\n";
cin>>x;


if (x == 1)
cout<<add();
cout<<endl;

if (x == 2)
cout<<subtract();
cout<<endl;

if (x == 3)
cout<<multiply();
cout<<endl;

if (x == 4)
cout<<division();
cout<<endl;

if (x == 5)
cout<<"You're quitting? Lamesauce. Toodles.\n";
cout<<endl;

}

Let me know if that's what you are looking for.

Grn Xtrm 84 Posting Pro in Training

Your function can be written in a much better way using greater than and less than signs, as well as the AND (&&) operator in the if statements. I rewrote your function and ran it successfully:

int qualityPoints (int mark)
{ 

if (mark >= 60 && mark <70){
cout <<"1";
}

else if (mark >= 70 && mark <80){

cout <<"2";
}

else if (mark >= 80 && mark <90){

cout <<"3";
}

return mark;
}

This tests if the input average falls within a specific range of numbers instead of testing for each number as you had originally tried. Hope this helps.

Grn Xtrm 84 Posting Pro in Training

Use a while loop around the text of the main()

while(1)
{
menu();
}

You haven't included the menu function, so I can't test it for sure. I changed the menu function in the main to multiply, and i created an infinite loop where the computer kept asking for two numbers to multiply.
I assume you want to do this with the menu function. I hope that helps and is actually what you were looking for ;)

Grn Xtrm 84 Posting Pro in Training

I dont understand this question at all. Can you please rephrase? The code you supplied doesnt make any sense. 1 will never equal 2 or 2 or 2...;)

Grn Xtrm 84 Posting Pro in Training

I'm having trouble seeing where you are using the Employee class in your Payroll3 class. I can't see where you are calling the methods or constructing objects from the class. The main method is where you call methods and put them to use, but not where you write the method itself.

Grn Xtrm 84 Posting Pro in Training

I believe the problem with your Employee class is because you have the constructors and methods defined in the main method. It doesnt appear to me that you need to have a main method in that specific class.

Grn Xtrm 84 Posting Pro in Training

The condition in the while loop will be the same as the for loop, namely the count is less than 51. Then just display the current count, and then increment the count variable by one.
This snippet (which I wrote in c++) displays what I just said,

int count=1;
    for(count; count<51; count++)
    cout<<" "<<count;
    
    while(count<51)
    {
      cout<<" "<<count;
      count++;
    }

Both loops do the same thing. I think thats what you are looking for.

Grn Xtrm 84 Posting Pro in Training

The cmath library has built in functions to calculate the sin, cos, and tan. Look here for more info:
http://www.cplusplus.com/reference/clibrary/cmath/

Nick Evan commented: That'll do just fine! +10
Grn Xtrm 84 Posting Pro in Training

You gotta be some kind of loser to go and downvote over 6500 posts from one of the best and well respected members in the community. Seeing Ancient Dragon's post quality at 34% is a joke. It's time for the up/down vote system to make its exit. It's always good to try something new, but you have to know to scrap it when its not working as intended. William's observation proves that this system is dead and cannot work as long as immature people are members of the community.

jephthah commented: yup +0
Salem commented: Well said +0
Grn Xtrm 84 Posting Pro in Training

Use a for loop that ranges from 1 to the number input by the user.

int times;
for(int i = 1; i <= times; i++)
{
//do actions
}//close for loop

Hopefully this can help you get started.

Grn Xtrm 84 Posting Pro in Training

The only time I listen to Oasis, is when I watch videos of them getting their asses kicked on stage.

I take it you don't like Oasis :D
My band wanted to do a cover of Wonderwall so I just went with it. But it is a really good song in my opinion. But to each his own.

Grn Xtrm 84 Posting Pro in Training
Grn Xtrm 84 Posting Pro in Training

I want a Rickenbacker 4003 bass, but I know I'm not gonna get it ;)

Grn Xtrm 84 Posting Pro in Training

Reading the dumbest thread I've ever seen :)
Just kidding I've seen dumber. ;)

Grn Xtrm 84 Posting Pro in Training

Hysteria by Muse. I've been able to replicate the awesome bass with a Bass Overdrive pedal from Boss. Sounds so cool. :cool:

Grn Xtrm 84 Posting Pro in Training

In the if/else statements you have to use for example

chocCount = chocCount + count;

This will add the current value of chocCount to count. You need to repeat this for each flavor. I think this is what you are looking for.

Grn Xtrm 84 Posting Pro in Training

Here is a few pics
The green one is the new one, the other one is the old Shergold.

Those are both pretty nice. Of course I can't really judge the, without hearing how they sound. Have you made any videos and posted them, say on Facebook? If yes, let me know. I'd love to hear you play.
Sorry, to get off topic like this... ;)
But I'd also bring my amp and my Overdrive pedal, along with two cables.

Grn Xtrm 84 Posting Pro in Training

When you are incrementing the counts just use flavorName++;
By the way your teacher is a jerk.

Grn Xtrm 84 Posting Pro in Training

Well, there are a few changes that need to be made to your current code. First, you need to make count an int value not a string. You cant set strings equal to an integer value.
The switch statement should be 'switching' on the flavor not the count. Inside each statement you should increment that specific flavor. You will need to include separate counters for each flavor.
Line 81: this is not a recursive function and therefore you cannot call the function within the text of the function.
Finally, you cant return more than one value.

Now I'd like to offer my personal take on the problem. I'd use a while loop like the following:

while(flavor != "STOP" ||  flavor != "stop")

Then use a switch statement with separate incrementers for each flavor. When input is terminated, output the results of each counter. Well, there's my two cents. Let me know if you need any clarification on that.
EDIT - sorry Ancient Dragon, I didnt realize you had already posted.

Grn Xtrm 84 Posting Pro in Training

On and off for about 3 or 4 years. Had a vintage shergold which i loved but that died so now ive got some korean thing (which actually is surprisingly great!)

Yeah my Hofner is actually a cheap Chinese model, but also plays quite nicely. Somewhere down the road I want to buy a Rickenbacker 4003 bass. The only problem is that it costs $2000. That's alot of cash for something I don't really need. But I can still dream... ;)