Duki 552 Nearly a Posting Virtuoso
else if ( answer == 'y' || answer == 'Y' )
    {
        cout << "How many toppings would you like (maximum of 7)?" << endl ;
        cin >> i ;
        cout << "Please choose from the following list:  " << endl ;
        cout << "\t1. Extra Pepperoni \t2. Extra Cheese" << endl ;
        cout << "\t3. Sausage         \t4. Jalapenos" << endl ;
        cout << "\t5. Banana Peppers  \t6. Green Peppers" << endl ;
        cout << "\t7. Mushrooms       \t8. M&Ms" << endl ;
        cout << "Enter " << i << " topping numbers, followed by the 'Enter' key:  " << endl ;
        for ( i = 0 ; i < 7 ; i++ )
        {
            cin >> a[i] ;
        }
    }

am i doing something wrong here?
I only want to input the specified number into the array but it's making me input data for the entire array before moving on.

Duki 552 Nearly a Posting Virtuoso

ah wonderful!

I'm getting closer, but i need your help yet again.

Do you see the logic error in this part of my code?

edit]: stupid mistake; code deleted

Duki 552 Nearly a Posting Virtuoso

they match:

prototype:

void set ( char , char , int & , int ) ;

function:

void Pizza::set ( char x , char y , int (&a)[7] , int i )
{
    type = x ;
    size = y ;
    for ( int x = 0 ; x < i ; x++ )
    toppings[i] = a[i] ;
}

call:

pizza.set ( x , y , a[6] , i ) ;

edit]: I haven't used arrays since last year, so forgive my ignorance on them for now :(

Duki 552 Nearly a Posting Virtuoso

great, but now i get an overloaded function error on the same function.

prototype: void set ( char , char , int ) ;

Duki 552 Nearly a Posting Virtuoso

Oh ok, I still don't quite get it but it's making more sense now.

is there something wrong with this part of my code? I get an error saying arrays of refrences are illegal

#include "prob7.h"

void Pizza::set ( char x , char y , int & a[7] )
{
    type = x ;
    size = y ;
    toppings = a ;
}

void Pizza::ouputDesc ( int i ) 
{
    cout << endl << "Style:  " << style << endl ;
    cout << "Size:  " << size << endl ;
    cout << "Toppings:  " << flush ;
    
    for ( int x = 0 ; x < i ; x++ )
        cout << toppings [ i ] << ", " << flush ;
}
Duki 552 Nearly a Posting Virtuoso

I did follow the link, still didn't make sense

Duki 552 Nearly a Posting Virtuoso

Good. Then don't do this:
Having the using namespace std basically defeats the purpose of a namespace. And putting it in the header is known to cause problems down the line.

so do like std::cout << ?

And the #pragma once thing is platform-specific. Include guards are what I would prefer.

I don't understand how to use the Include gaurds; could you explain them?

For the toppings, I figured the easiest way is to do a loop of some sort until they're finished inputting toppings (maximum of 7). The reason I'm using an array is because I have to include a function that outputs the object data, including each topping.

Make a member function void add_topping(int topping_number), that adds a topping. Or make an extra array. It's not like it's a big deal, to make an extra array.

alright, just wanted to make sure there wasn't an easier way. thanks

And what is 'outputDesc' for? You're having a pizza class that can output its information? That violates the principle you've described. (And what is 'set', too?)

I'm not sure I understand; why shouldn't I do outputDesc? I need some way of diplaying a list of information that has been input.
Set is the function that sets the values for type/size/toppings

Duki 552 Nearly a Posting Virtuoso

My prof is touching on information hiding, and good programming techniques. He said it's a good idea to keep as much of the user interface (i.e., couts) in main, and then modify object variables through the use of functions.

Here's what I want to do:
I'm starting on a program that lets the user input the type of pizza (hand tossed, pan, deep dish), the size (s, m, l) and the toppings they want.

So far, here's what I've setup in my class:

#pragma once

#include <iostream>
using namespace std ;

const double SMALL = 10.00
const double MEDIUM = 14.00
const double LARGE = 17.00
const double TOPPING = 2.00

class Pizza
{
public:
    void set ( ) ;
    void outputDesc ( ) ;
    double computePrice ( ) ;
private:
    char type ;
    char size ;
    int toppings[7] ;
} ;

For the toppings, I figured the easiest way is to do a loop of some sort until they're finished inputting toppings (maximum of 7). The reason I'm using an array is because I have to include a function that outputs the object data, including each topping.

My question is this: How can I allow the user to input the toppings they want in main(), and then put that data into the array in my object without creating a temp array for user input?

Duki 552 Nearly a Posting Virtuoso

ah, gracias!

Duki 552 Nearly a Posting Virtuoso

Hey guys,

Just got started on this, and I keep getting an error saying Missing ";" before "." starting at line 25 and pretty much on all of my functino calls in main.

Anyone know what I'm doing wrong?
Here's my code:

//driver - main
#include "prob6.h"

int main ( )
{
    int a = 0 ;
    int selection ;
    double fuelEff ;
    double miles ;

    do
    {
    cout << "Make a selection" << endl ;
    cout << "1. Enter fuel effeciency (in MPG):  " << endl ;
    cout << "2. Add miles to odometer:  " << endl ;
    cout << "3. Reset odometer:  " << endl ;
    cout << "4. Output gallons consumed:  " << endl ;
    cin >> selection ;

    switch ( selection )
    {
    case 1:
        cout << "Please enter the vehicle's fuel effeciency in MPG:  " << flush ;
        cin >> fuelEff ;
        Odometer.setMPG ( fuelEff ) ;
        break ;
    case 2:
        cout << "Please enter the miles in which to add to the current odometer reading:  " << flush ;
        cin >> miles ;
        Odometer.setOdom
        break ;
    case 3:
        Odometer.resetOdom ( ) ;
        cout << "Odometer has been reset" << endl ;
        break ;
    case 4:
        Odometer.outGalConsumed ( ) ;
        break ;
    case 5:
        a = 1 ;
        break ;
    default:
        cout << "Invalid selection - Please limit selection to numbers 1 through 5" << endl ;
    }
    } while ( a == 0 ) ;

    return 0 ;
}




//functions
#include "prob6.h" …
Duki 552 Nearly a Posting Virtuoso

You're talking about the off-by-one errors? You were converting a floating point number to an integer, which is done by truncation. When you try to compute the sine of pi/2 with the inaccurate approximation you had there, you get something like 0.99999394829..., instead of 1. Then, multiplying that by an integer (for example, 5) produces a number slightly less than 5, like 4.99996... Then converting this to an integer truncates, giving 4. If you're going to allow free rotation of points (as you've mentioned the possibility), it doesn't really make sense unless you use doubles to represent the coordinates.

oh ok; that makes perfect sense, thanks!

Since you've done your due diligence Duki, and I messed around with this assignment myself, here is what I had come up with (and one quick last-minute change credited to Rashakil Fol).

#include <iostream>
#include <cmath>

static const double pi = 4.0 * std::atan(1.0);

class point
{
   double x, y, radius, angle;
public:
   point(double x_ = 0, double y_ = 0)
   : x(x_), y(y_), radius(std::sqrt(x * x + y * y)), angle(std::atan2(y, x))
   {
   }
   void rotate(double radians)
   {
      angle += radians;
      x = radius * std::cos(angle);
      y = radius * std::sin(angle);
   }
   friend std::ostream &operator<< (std::ostream &o, const point &p)
   {
      return o << p.x << ',' << p.y;
   }
};

int main()
{
   point A(3,2); // A(-3,2);
   std::cout << A << '\n';
   for ( int i = 0; i < 12; ++i )
   {
      A.rotate(-pi / 6);
      std::cout << A << …
Duki 552 Nearly a Posting Virtuoso

If you're rotating 270 degrees (or any multiple of 2pi/4 radians), there's no reason to be using trig functions. Just replace (x,y) -> (y,-x). That's what your code simplifies to, once you replace cos(angle) with 0 and sin(angle) with 1. You don't really need to know trig for this, just congruent triangles :-)

Also, make a habit of thinking in radians (which is just a way of describing angles as a fraction of a full circle). It's useful. Always look upon degrees as inferior, except when navigating. It helps if you remember that 2pi is a fundamental constant, while pi is merely 2pi/2, and a quarter circle is 2pi/4, etc. The people who decided that 3.141... was worthy of a name while 6.283... was not were noobs.

Also, in your implementation above, you really shouldn't hard-code the constant 2pi/4. Write it as SOME_NAME_FOR_PI/2. The only reason for this is that your constant doesn't have all the digits you need -- and you don't want to go around copying some random mathematical constants all over the place, to 16 decimal places or whatever is needed to completely fill the floating point mantissa you're using. It's much easier to remember the name. You'll suffer inaccuracy from using a constant that only goes to a paltry 8 decimal places. And you're using floating point numbers which gives you inherent accuracy. For rotating integers 90 degrees, using floating point math is just immoral :-) You're getting errors not from the inaccuracy of your constant …

Duki 552 Nearly a Posting Virtuoso

Ok, now I'm getting output, but it's 1 off (for x). The y values are still right.

Here's my updated function:

void Point::rotate ( int rx , int ry )
{
    angle = 1.57079633 ;
    x = rx * cos(angle) + ry * sin(angle) ;
    y = ry * cos(angle) - rx * sin(angle) ;
    cout << x << " " << y << endl ;
}
Duki 552 Nearly a Posting Virtuoso

ah! son of a...

thanks!

Duki 552 Nearly a Posting Virtuoso

Just happened to think someone may want to put my code in their compiler; here's all of my code (see attached).

Duki 552 Nearly a Posting Virtuoso

I'm getting ready for bed, but if someone could give me a hand in the next couple minutes I would really appreciate it!!

Here's my current delima:

//header

#pragma once

#include <cmath>
#include <iostream>
using namespace std ;

class Point
{
public:
    void menu ( ) ;
    void set ( int , int ) ;
private:
    void movePoints ( int , int ) ;
    void rotate ( int , int ) ;
    void getX ( ) const ;
    void getY ( ) const ;

    int x ;
    int y ;
    int rx ;
    int ry ;

    double angle ;
};

//other relevant code
//header file
#include "prob3.h"

//driver function
int main () 
{
    Point PointOpp ;

    int xCoord ;
    int yCoord ;

    cout << "Please enter your 'x' coordinant:  " << flush ;
    cin >> xCoord ;
    cout << "Please enter your 'y' coordinant:  " << flush ;
    cin >> yCoord ;

    PointOpp.set ( xCoord , yCoord ) ;
    PointOpp.menu ( ) ;

    return 0 ;
}

//last of relevant code
void Point::menu ( ) 
{
    int a ;
    int opp ;
    int xAm ;
    int yAm ;

    do
    {
    cout << "1.  Move the point" << endl ;
    cout << "2.  Rotate the point by 90 degrees" << endl ;
    cout << "3.  Print 'x' value" << endl ;
    cout << "4.  Print 'y' value" << endl ;

    cout << "Please specify an opperation:  " << flush ;
    cin >> opp ;

    switch ( opp )
    {
    case …
Duki 552 Nearly a Posting Virtuoso

ha! Isn't it horrible when you have to spend more time on the math fundimentals than on the programming?

Duki 552 Nearly a Posting Virtuoso

Ok i've tried my equation with multiple expamples and i think it works, but why am i getting the wrong output?

for output i get x = 0 y = -3; x should be 2, y is right.

Duki 552 Nearly a Posting Virtuoso

Ok, here's how I am doing it; is this wrong?

#include <cmath>
#include <iostream>
using namespace std ;

int main () 
{
    int x ;
    int y ;
    double angle ;
    int rx ;
    int ry ;

    angle = 90 ;
    x = 3 ;
    y = 2 ;
    rx = x * cos(angle) + y * sin(angle) ;
    ry = y * cos(angle) - x * sin(angle) ;

    cout << rx << " " << ry << endl ;

    return 0 ;
}

something is wrong, because for x i get 0 output, but when i do it in my calculator i get the right answer (2) !

Duki 552 Nearly a Posting Virtuoso

x' = x * cosine(90) + y * sine(90)
y' = x * sine(90) - y * cosine(90)

that look right?

edit] i think these are the right ones:

rx = x * cos(90) + y * sin(90) ;
ry = y * cos(90) - x * sin(90) ;

Duki 552 Nearly a Posting Virtuoso

Thanks Dave; any tips as to which ones? ;)

Hamrick: sorry I didn't clarify. There is an assumed point (i'm guessing) that is constant at (0,0).

Duki 552 Nearly a Posting Virtuoso

Hey everyone, I'm back in C++ this semester; Last semester I went through Structured C++ (and passed with a 4.0; many thanks to all of you!) and this semester I'm in OOP.

I don't have sample code yet because I haven't started. But I was talking to a classmate, and one of our programming exercises wants us to write a function that will modify a point (i.e., (3, 2)) so that it will rotate it 90 degrees, clockwise. Is there an easier way to do this rather than 5 or 6 "If" statements?


Example scenario:

I input point x as 3 and point y as 2. I select the option to rotate the point by 90 degrees and should get x as 2 and y as -3.

Duki 552 Nearly a Posting Virtuoso

rofl.

so i read this page http://www.daniweb.com/forums/thread85817.html

and then i was like hm, wonder how long the thread is... so i clicked Last.

allow me to bring us back on topic.

"i didn't know i couldn't do that"

Duki 552 Nearly a Posting Virtuoso

Bragging:
For the first week (starting tomorrow) I'm headed to Savannah, GA to train directly under a CCIE for 4-5 days. Can't wait.

Bragging again:
The day after my planned return, Tina, her family, and myself are going to Cedar Point and Sandusky, OH for 3 to 4 days! Woohoo!

Information:
The following week, I'll be going all over the state installing the routers/servers we configured in Savannah... so I won't be on a lot that week either.

Not that I'm on that much anyways...
See you guys in a few weeks.

christina>you commented: have fun! xoxo +21
Duki 552 Nearly a Posting Virtuoso

that's cool.. but did you skip two questions on a testlet?
I wonder what my real score should have been :D

Duki 552 Nearly a Posting Virtuoso

word, thanks

Duki 552 Nearly a Posting Virtuoso

So, does the vendor really matter?

Duki 552 Nearly a Posting Virtuoso

We have a HP designjet 1050c printer here at work. We can print to it fine using batch files, but if we send more than print at a time, the printer doesn't cut the sheet before going to the next.

any clue?

Duki 552 Nearly a Posting Virtuoso

When did you take it?
The new test doesn't allow you to go back and review your answers. :(

Duki 552 Nearly a Posting Virtuoso

my parents trust everything i say.... but then again, we live in WV; the computer has only been around for a month or two :P

Duki 552 Nearly a Posting Virtuoso

^

is my girlfriend. :D
(hey... that's a compliment right?)

Duki 552 Nearly a Posting Virtuoso

Yay, Duki passed! :)

Congrats!

Thanks babay!


So yeah, I passed with a 900/1000. Not bad for accidentally skipping two parts to a question. :) I wonder why they don't allow you to go back and check/change your answers... =/.

joshSCH commented: Congrats, man :) +17
christina>you commented: yay for being smart! +21
Duki 552 Nearly a Posting Virtuoso

Hope I don't fail :x

christina>you commented: you better not fail. ;) +21
EnderX commented: I wish you well, my friend. +4
Duki 552 Nearly a Posting Virtuoso

so if i buy a sweet soundcard, but my headphones are USB, will i get any benefit from the soundcard? or also, if I had a standard hookup, but hooked them into my speakers, would i see any benefit?
heeelllllp

Duki 552 Nearly a Posting Virtuoso

of course they're not the same... but wrong forum? where's the right one then, since it was obviously worth giving me bad rep...

I mean I did put "new to scripting".....

Duki 552 Nearly a Posting Virtuoso

What can vbs do that .bat files can't?

Duki 552 Nearly a Posting Virtuoso

Also, could someone show me a good book to buy for beginners?

I was looking at the Microsoft VBscript step by step... but wanted to get your opinions.

iamthwee commented: wrong forum -2
Duki 552 Nearly a Posting Virtuoso

Could someone point me to a tutorial on how to write a vbscript that will auto install software when the user logs on?

I will be applying this to a GPO.
Also, will I need a (not sure if this is the right name for it) answer file/script to attach to it for silent installs?

If you can't tell... I'm new to scripting.

Duki 552 Nearly a Posting Virtuoso

MCSE is very highly respected in the field; probably one of the top 5 certifications looked for by big time employers.

Don't worry about what's next after the MCSE. This certification consists of 7 exams, and is sure to take you at the very least 2 years to complete. If you want to know the material thoroughly, devote 4 years to it.

Some people go to college for 4 years for this certification.... Don't rush it.

Duki 552 Nearly a Posting Virtuoso

meh, i thought to myself.... if someone is really considering win98 in 2004... they probably can't do anything like reformat or install drivers. Thus, I chose computer 1, as they probably just need something that is fully functional.

Duki 552 Nearly a Posting Virtuoso

well you never know. they could come back.

Duki 552 Nearly a Posting Virtuoso

ha! i said eh one more time before bed. It was actually 2 more, but still... i beat lvl28

joshSCH commented: Happy Independence Day! :) +15
Duki 552 Nearly a Posting Virtuoso

made it lvl28 and quit... spent like 20 minutes on that level.
http://www.addictinggames.com/bloons.html

joshSCH commented: Tight game ;) +15
maravich12 commented: Pretty good.Sometimes the dart doesn't bounce. +2
Duki 552 Nearly a Posting Virtuoso

welcome to the forum

Aia commented: Duki you are the man. +6
christina>you commented: lmao +19
Duki 552 Nearly a Posting Virtuoso

computer 1

Duki 552 Nearly a Posting Virtuoso

i got 332 =\

Duki 552 Nearly a Posting Virtuoso

or avg :)

Duki 552 Nearly a Posting Virtuoso

i watched about a minute and a half of it and cut it off... just seemed unprofessional and the music was annoying.

Duki 552 Nearly a Posting Virtuoso

inspiring films:

The Guardian
The Pursuit of Happyness
300
We Were Soldiers
more to come....

Duki 552 Nearly a Posting Virtuoso

yes, we're going to be using FireBox