Grn Xtrm 84 Posting Pro in Training

No one will give you help if you show no effort. Try it and tell us of your specific problems.

Grn Xtrm 84 Posting Pro in Training

I realized a few problems with the code I suggested, sorry.
As Dave pointed out you need (if a == "true"), however to fit your code I would just create an int value to hold the input of either 1 or 2.

int mult_or_div;
    cout << ("Multiply = 1 or Divide = 2 ?\n");
    cin >> mult_or_div;
    
    if( mult_or_div == 1)
    {
        goto Multiply;
    } 
    else 
    {
        goto Divide;
    }

One more problem. You need a second cin>> in your divide block. You never recieve the input for your second number.

Grn Xtrm 84 Posting Pro in Training

The first game I played on a computer was Putt Putt Goes to the Moon when I was about 5 years old.
http://www.games2download.com/free-kids-games/putt-putt-goes-moon.htm
The first video game I played was Bonk on the Turbo Graf-X 16 console.
Great memories :)

Grn Xtrm 84 Posting Pro in Training

OK, so in that case why did GM deliver us crap for so many years (and note that I come from a GM family - my father who died at 83 a couple of years ago, never owned anything but GM till he bought a Chrysler minivan in 2000)? You make the assumption that a company is capable of having any long term view past the next quarterly report, and it seems that many companies aren't capable of doing that.

GM used to make great cars. My dad used to own two GM cars and both lasted for over 20 years. I'm no car expert but why do you think GM is doing so poorly nowadays? Because people picked up on the fact that they make a crappy product, so people stopped buying them. Thank you for proving my point for me.

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

Their best interests also has to satisfy our best interests, or they will quickly lose users, so no I don't agree. A good OS will attract more users, and it's not like Microsoft hasn't got enough money to provide us with a good one.

Well, obviously they aren't gonna purposely make a poor product just to spite us. ;)
They want to make a good product so they will make as much money as possible. That's what big corporations care about. MONEY. And the best way to make alot of money is to make a good product that lots of people will buy. I agree with you there.

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

Heh. Of course I'm anti-Microsoft! I have seen the light children, and the light is FREE SOFTWARE! Protect us from the EVILS of the Proprietary Software Manufacturers WHO SELL US OUT TO THE RIAA and install SPYWARE (Windows Genuine Disadvantage) on our COMPUTERS!

Obviously you are anti microsoft. But you never admitted to being a troll. ;)

Seriously though - do you trust Microsoft? Do you trust Apple? You shouldn't. They are working towards their own best interests, which quite probably are not your best interests.

Of course I don't trust them. They are large multi billion dollar industries. Finally, something I can agree with you on. :)

Of course you can trust me, I'm a paragon of virtue, and would never mislead you.

LOL. Hey, your kinda funny when your not raving like a lunatic. ;)

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

If you intend to check if each r value is less than or equal to 1 then you must say

if(r3 <= 1 && r2 <= 1 && r1 <= 1 && r0 <= 1 )...

Do this for each of your statements that are not working correctly.
This should resolve your problem.
Is this your problem?

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

So how did my suggestions work out for you?
If they worked for you as they did for me, your code should be running correctly. That said, please mark the thread as solved if you have no further questions.
Thanks.

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

You have a few problems with your code. First off, the Multiply and Divide blocks must be contained in main().
Secondly you cant redeclare x and y in Divide when theyy are already being used by Multiply.
Lastly, I think the colon should come after the word (ie Multiply or Divide)
I ran the code using these adjustments.

Grn Xtrm 84 Posting Pro in Training

I just realized again that the code in my last post is flawed.

if(rows == 7)   
rows=rows-3;    
if(rows == 1)    
rows=rows;

These two if statements hsould be else if.
But that is not really the issue here. ;)
Sorry to make so many consecutive posts. I really need to proofread my code before posting it.
I have constructed the 2d array as such

char board [rows][cols];

I'm struggling to find a way to fill it properly and output the correct pattern. Any help would be greatly appreciated. Thanks.

Grn Xtrm 84 Posting Pro in Training

First of all please use code tags when posting code. Thanks.
Your variable names cant have spaces. Make it one word or put underscores between the words.
const should start with a lowercase c not capital.
Obviously you'll also need to set a return value of 0 and close the main() with a }

Grn Xtrm 84 Posting Pro in Training

Use cout and cin to obtain user input.
Use if statements to test if the input is valid.

Grn Xtrm 84 Posting Pro in Training

Have you tried to solve the problem yourself?
Post your code and we will offer some suggestions.

Obviously you will need interactive input so use

//to prompt the user for input use
cout<< ...
//to obtain input from the keyboard use
cin>>...
Grn Xtrm 84 Posting Pro in Training

I resolved the problem for the nested if statements by using a series of if statements
Here is my revised code:

#include <stdio.h>
 
int main()
    {
    int i, j, k, rows;
    char wait;
    printf("Specify the number of rows (between 1-9) in the dimond: ");
    scanf ("%d",&rows);
    scanf("%c", &wait);
    printf("\n");
    if(rows == 9)
    rows=rows-4;
    else if(rows == 7)
    rows=rows-3;
    else if(rows == 5)
    rows=rows-2;
    if(rows == 7)
    rows=rows-3;
    if(rows == 1)
    rows=rows;
    else
    printf("Invalid input\n");
    for(i=1; i<=rows; i++)
        {
        for(j=1; j<=rows-i; j++)
        printf("%c",' ');
        for(k=1; k<=2*i-1; k++)
        printf("%c",'*');
        printf("\n");
        }
        int l,m,n;
        for (n = rows-1; n > 0;n--)
        {
        for (l = 1; l <= rows- n; l++)
        printf("%c",' ');
        for (m = 1; m<= 2 * n- 1; m++)
        printf("%c",'*');
        printf("\n");
        }
        printf("Enter any key to end");
        scanf("%c", &wait);
            return(0);
       }

If any one has a more efficient way than using if/else please let me know.
Still looking for some input on a 2d array solution.

Grn Xtrm 84 Posting Pro in Training

Hello friends. I'm trying to write a program that accepts an odd number from 1-9 and outputs the diamond of asterisks as follows

user enters 5
_ _ _ * _ _ _
_ _ * * * _ _ 
_ * * * * * _
_ _ * * * _ _ 
_ _ _ * _ _ _

I was able to accomplish the problem using nested for loops but I then realized that I needed to use a 2d array, which is a new topic to me. I need help re writing the following program to include a 2d array.
Here is my original code than runs with nested for loops:

#include <stdio.h>
int main()
    {
    int i, j, k, rows;
    char wait;
    printf("Specify the number of rows (between 1-9) in the dimond: ");
    scanf ("%d",&rows);
    scanf("%c", &wait);
    printf("\n");
  
    for(i=1; i<=rows-2; i++)
        {
        for(j=1; j<=rows-i; j++)
        printf("%c",' ');
        for(k=1; k<=2 * i-1; k++)
        printf("%c",'*');
        printf("\n");
        }
        int l,m,n;
        for (n = rows-3; n > 0;n--)
        {
        for (l = 1; l <= rows- n; l++)
        printf("%c",' ');
        for (m = 1; m<= 2 * n- 1; m++)
        printf("%c",'*');
        printf("\n");
        }
        printf("Enter any key to end");
        scanf("%c", &wait);
         return(0);
       }

I'm really having trouble understanding how to fill the 2d array with the appropriate number of asterisks.
I wrote a function to print the array:

void printArray(char array[MAXROW][MAXROW], int rows)
{
    int r, c;
    for(r = 0; r < rows; r++)
      { …
Grn Xtrm 84 Posting Pro in Training

As to your Linux lab - I note that you didn't compare the hardware. I saw one lab like you are talking about, where all of the Linux machines were old P3 units, and the Windows machines all Core 2 Duo. And yes, people were wondering why the Linux computers were slower!

How would you know what kind of computers are in the labs at my school? They are actually all the same but nice try.

Oh, and a correction. I don't call people trolls because they like Windows. I call people trolls because of their actions.

OK, then you are an Anti-Microsoft troll... because of your actions, of course.

Grn Xtrm 84 Posting Pro in Training

This is rather amusing. I posted a long, insightful write up on why I don't use Windows. And guess what - my reputation is instantly modded down. Now why would that be. Is it possible that Microsoft Trolls hang out here?
I think so.

Maybe there are people out there who like Windows. Is that allowed?
There is a Linux lab at my school and those computers are slowest machines I ever used. Every other room in the school has computers that run Windows and they work much better. In my experience Windows is much better than Linux. But hey, that's just me. I'm sure others have had great experiences with Linux.
People are entitled to their opinions. Don't call people trolls because they like to use Windows.

Grn Xtrm 84 Posting Pro in Training

Ok. Whatever. This is not a forum for exchanging verbal abuse, it is a forum designed to help with writing and understanding programming code (and other computer related topics). I'm sorry I could not be of more help and I hope you will come to a quick resolution to your problem.
Good luck.

Grn Xtrm 84 Posting Pro in Training

You don't have to destroy my credibility because you don't like the way I answered your questions. Maybe someone else will read your post and be of more service. Down voting is supposed to be for posts that are unrelated to the topic or disobey the forum rules or are incorrect. Not to get even with someone who will not answer your questions the way you want.

Grn Xtrm 84 Posting Pro in Training

You want to run the game while the number of incorrect guesses is less than 7, and you want to increment the number if incorrect guesses each time the user makes a wrong guess.
So, each time the user makes a wrong guess you should do:

++inCorrectGuess;

As for the first part, put your code that exectes the game in a while loop:

while(inCorrectGuess < 7)
{............
......
}

I hope that helps clarify your problem.
Don't post the same question 3 times in the future.

Grn Xtrm 84 Posting Pro in Training

Here is how a program containing a function should look:

#include <iostream>
using namespace std;
//here you put the function prototype as I posted earlier
//now begin main()
int main()
{
// here you put the text of the main function--including 
//variable declarations and initialization, function calls, etc.
return 0;
}
//now you write your function
Grn Xtrm 84 Posting Pro in Training

I still didnt get an answer to my questions though?

Oh, that's too bad. :(
By the way, "I don't know how to do this" is not a question.
You need to let the community know what errors the compiler is reporting so we can help you more easily and more effectively.

Grn Xtrm 84 Posting Pro in Training

Why don't you use a vector of integers instead of booleans?
Add the integer values to the vector, and then print them out.
If I am misunderstanding the question please let me know.

Grn Xtrm 84 Posting Pro in Training

Function prototypes must be declared before the main().

void smallAverage(int *myArray, float *average, int *numSmallerThanAverage);
int main()
{
//text of main
return 0;
}

//now begin function

Functions should appear after the main() function.

Grn Xtrm 84 Posting Pro in Training

I have dled the JDK.
Now I have Jdk and Drjava.
But now when I try to run this program there like like 14 errors.......
I don't get it..

Let us see the errors.
The class in which the Disk constructor is defined must be in the same folder/directory as the TestDisk class.
You do have a file with the Disk constructor right?... Or did you actually just copy that one part out of your book?

Grn Xtrm 84 Posting Pro in Training

Read this if you have trouble finding the compiler or have any other questions
http://www.daniweb.com/forums/thread99132.html#

Grn Xtrm 84 Posting Pro in Training

Do you have the java compiler downloaded? When I first started Java I had trouble finding the compiler online (i think it was called JDK or something like that). You need this to run java code and I dont believe it comes with Java implementation environments such as Jcreator, TextPad, etc.

Grn Xtrm 84 Posting Pro in Training

The name of the file should be the name of the class in an example like this one. Save your file as TestDisk.java
Did you mean to put the '.' in between Test and Disk?

Grn Xtrm 84 Posting Pro in Training

I realized that the error messages were not displaying properly in your last attempt. Here is the revised body of the program:

cout << "Please enter an integer between 0 and 100: ";
cin >> num1;

if (num1 >= 0 && num1 <= 100)
{
cout << "Please enter an integer between " << num1 << " and 100: ";
cin >> num2;
}

if( num2 >= num1 && num2 <=100)
{
for(int i=num1; i<=num2; i++)
sum += i;
cout << "The total of the integers between " << num1 << " and " << num2 << " is: " << sum<<endl;
}

else
{	
cout << "Please read and follow the directions!"<<endl;
}

This is much clearer and efficient than the code I originally proposed to you.

Grn Xtrm 84 Posting Pro in Training

In this most recent attempt, you followed my second suggestion but not my first. You must set a return value.
Use

return 0;

before the last brace.

Also I was able to run the code by removing one of the braces after the for loop.

Grn Xtrm 84 Posting Pro in Training

I am getting no compile errors when running your code.
I ran the code successfully by changing the while to a for loop:

for(int i=num1; i<=num2; i++)
sum += i;

This for loop sums up the numbers between num1 and num2 inclusive.

Grn Xtrm 84 Posting Pro in Training

If think you are leaving out the return value.
Put

return 0;

before the final brace terminating the main() function.
Unless you didn't post your entire code...

Grn Xtrm 84 Posting Pro in Training

I doubt having a good job related to technology is the reason for your cousin's health problems and physical appearance.

niek_e's sarcastic comment is right. Life expectancy is much higher today because of advances in technology.

Grn Xtrm 84 Posting Pro in Training

Please tell me the major difference between the capital character with single inverted comma and double inverted comma in a C Program.

They are called single quotes and double quotes. ;)
LOL. Inverted comma...

Grn Xtrm 84 Posting Pro in Training

Oh, I've never tried including the class in more than one file that way. I wish my C++ teacher would have taught me the right way. ;)
Thanks, Dave.

Grn Xtrm 84 Posting Pro in Training

Following up on the previous post, put your scanners after each related print statement. For example:

System.out.println( "Enter forename" );
forename = scanner.nextLine();

Repeat for the others.

Grn Xtrm 84 Posting Pro in Training

Sooner or later you'll need to learn that this is the wrong thing to do. QUOTE]
Can you please explain why this is wrong? It's the way I learned in school and works exactly as I want it to. Is it actually wrong or is it just not the industry standard? Thanks.

Grn Xtrm 84 Posting Pro in Training

Thanks alot William. I have a few questions if you don't mind. First, does the book come with a CD that includes a program in which to create flash projects. If not, is there one available for download online (preferably for free :) ) Secondly, I've never done anything graphical before. Will I still be able to learn effectively from your recommended book? Lastly, do you happen to know roughly how much that book costs in American currency? Thanks again.

Grn Xtrm 84 Posting Pro in Training

When I use classes in other files I use:

#include "filename.cpp"

I put this line in the file containing my main() function. This lets you use the class in your main() function.

Grn Xtrm 84 Posting Pro in Training

Don't think that you need a teacher to learn programming, I'm totally self taught, meaning I can go at my own pace. If you do the same, you'll probably find yourself going at a faster pace than in school.

Thanks for the words of encouragement William. I've gotten quite good at C++ and Java by continuing myself after learning in school. I always wanted to learn Flash but never did. Maybe I will try during the winter break from school. I'm a little preoccupied with C and Linux now. ;)

Grn Xtrm 84 Posting Pro in Training

I wish I didn't, it's frustrating when you know you should be teaching the teacher how to program.

It's really great how someone as young as yourself has been able to become such a skilled programmer. I should have tried to learn while I was younger as well. Only thing is I didn't decide on taking up computer science until I was a senior in high school. Before that I was going to be an english major :zzz:
I'm so glad I decided in favor of comp sci.

Grn Xtrm 84 Posting Pro in Training

So do I -- but they didn't offer it in 1958 :)

LOL :)
But I graduated high school in 2007, though.
Still no love for the comp sci hopefuls in your typical catholic high school.

Grn Xtrm 84 Posting Pro in Training

You've posted the same question 3 times and haven't showed an ounce of work. Give it a shot and let us know what you think you should do. No one in this community is just going to give you a full program. If you work hard and believe in yourself, you can accomplish anything. Now go do some work. :)

Grn Xtrm 84 Posting Pro in Training

I'm not sure I know exactly what you are asking.
If all you need is to round to 2 decimal places, here is an example to help you:

double d = 1.234567;
        DecimalFormat df = new DecimalFormat("#.##");
        System.out.print(df.format(d));