iamthwee commented: Wrong forum, yet again. -2
christina>you commented: why are people so critical? it's not that serious. =p +15
I'm getting an error in main() saying TitledEmployee is an undeclared identifier?
#include <iostream>
#include <string>
using namespace std ;
namespace Employees
{
class Employee
{
public:
Employee ( ) ;
Employee ( string theName , string theSsn ) ;
string getName ( ) const ;
string getSsn ( ) const ;
double getNetPay ( ) const ;
void setName ( string newName ) ;
void setSsn ( string newSsn ) ;
void setNetPay ( double newNetPay ) ;
void printCheck ( ) const ;
private:
string name ;
string ssn ;
double netPay ;
} ;
Employee::Employee ( ) : name ( "No name yet" ) , ssn ( "No number yet" ) , netPay ( 0 )
{ }
Employee::Employee ( string theName , string theNumber ) : name ( theName ) , ssn ( theNumber ) , netPay ( 0 )
{ }
string Employee::getName ( ) const
{
return name ;
}
string Employee::getSsn ( ) const
{
return ssn ;
}
double Employee::getNetPay ( ) const
{
return netPay ;
}
void Employee::setName ( string newName )
{
name = newName ;
}
void Employee::setSsn ( string newSsn )
{
ssn = newSsn ;
}
void Employee::setNetPay ( double newNetPay )
{
netPay = newNetPay ;
}
void Employee::printCheck ( ) const
{
cout << "\nERROR: printcheck Function Called for an unidentified employee.\nAborting the program.\n" ;
exit ( 1 ) ;
}
class SalariedEmployee : public Employee
{
public:
SalariedEmployee ( ) ;
SalariedEmployee …
I'm trying to write an asp.net page that will keep variables using the .value command. It's not working. Here's my code
Dim custID As Integer
Dim noMovies As Integer
Dim price As Double
Dim discount As Double
Dim total As Double
custID = Integer.Parse(Me.idTextBox.Text)
noMovies = Integer.Parse(Me.numMovTextBox.Text)
price = noMovies * RENTAL_RATE
discount = price * DISCOUNT_RATE
total = price - discount
totSales += 1
'totSalesHiddenField.value = totSales.ToString() couldn't get this working for the life of me
totIncome += total
priceTextBox.Text = price.ToString("C")
discountTextBox.Text = discount.ToString("C")
totDueTextBox.Text = total.ToString("C")
totSalesTextBox.Text = totSales
totRevTextBox.Text = totIncome.ToString("C")
I keep getting errors that .value is not part of string, decimal, integer, etc
beagal bites and chicken nuggets... both microwaved and both killing me slowly from the inside out.
BBQ sunflower seeds (not quite as good as the jalapeno) and a Sierra Mist.
for the record: I wasn't serious about the water being harmful......
Oh ok great. thanks for the help! It's working great!
water is harmful....
I'm having some jalapeno sunflower seeds and a pepsi.
Oh, ok. so changing the array to static solved everything. It's still really slow, compared to this one:
#include <ctime>
#include <iostream>
using namespace std ;
int main ( )
{
int n ;
cout << "Enter number of elements: " << flush ;
cin >> n ;
int * fibArray = new int[ n ] ;
clock_t start ;
clock_t end ;
cout << "Beginning timer..." << endl ;
start = clock() ;
fibArray[ 0 ] = 1 ;
fibArray[ 1 ] = 1 ;
for ( int i = 2 ; i < n ; i++ )
fibArray[ i ] = fibArray[ i - 1 ] + fibArray[ i - 2 ] ;
for ( int j = 0 ; j < n ; j++ )
cout << fibArray[j] << "\t" ;
cout << endl ;
end = clock() ;
//cout.precision(1000) ;
cout << "\nThe calculation took " << showpoint <<( double ( end ) - start ) / CLOCKS_PER_SEC << " seconds.\n" ;
cout << "\n\n-- Done --\n\n" ;
cout << endl ;
return 0 ;
}
But that was expected; we get extra credit for programming both and timing the two.
I'm still frustrated that I can't do static int fibArray [ n ] instead of 25, or some other constant value.
Ok, I got it to work using a pointer. Here's my code.
#include <ctime>
#include <iostream>
using namespace std ;
int fib ( int ) ;
int main ( )
{
clock_t start ;
clock_t end ;
cout << "Beginning timer..." << endl ;
start = clock() ;
cout << endl ;
for ( int k = 0 ; k < 12 ; k++ )
{
int i = fib ( k ) ;
cout << i << "\t" ;
}
cout << endl ;
end = clock() ;
cout << "\nThe calculation took " << ( double ( end ) - start ) / CLOCKS_PER_SEC << " seconds.\n" ;
cout << "\n\n-- Done --\n\n" ;
return 0 ;
}
int fib ( int n )
{
int * fibArray = new int[ n ] ;
if ( n <= 1 )
return 1 ;
else
{
fibArray[ 0 ] = 1 ;
fibArray[ 1 ] = 1 ;
for ( int i = 2 ; i <= n ; i++ )
fibArray [ i ] = ( fib ( n - 1 ) + ( fib ( n - 2 ) ) ) ;
}
return fibArray[ n ] ;
}
I can't get it to work with numbers >=12; it gives a system error that it failed unexpectedly. I'm guessing it's a stack issue, but is there a way around it? Is my program the best it can be (using recursion and arrays)?
awesome thanks!
seeing as this is being discussed still, I would like to pose another question: How do I use an array using recursion? This will be more efficient, no? Here is my current code:
#include <iostream> using namespace std ; int fib ( int ) ; int main ( ) { int i = fib ( 5 ) ; cout << i << endl ; return 0 ; } int fib ( int n ) { int fibArray [ const n ] ; if ( <= 1 ) return 1 ; else { fibArray[ 0 ] = 1 ; fibArray[ 1 ] = 1 ; for ( int i = 2 ; i < 25 ; i++ ) fibArray[ i ] = ( fib ( n - 1 ) + ( fib ( n - 2 ) ) ) ; } return fibArray[ n ] ; }
why can i not do int fibArray [ n ] ? It says "expected constant"
jalapeno sunflower seeds.
seeing as this is being discussed still, I would like to pose another question: How do I use an array using recursion? This will be more efficient, no? Here is my current code:
#include <iostream>
using namespace std ;
int fib ( int ) ;
int main ( )
{
int i = fib ( 5 ) ;
cout << i << endl ;
return 0 ;
}
int fib ( int n )
{
int fibArray [ const n ] ;
if ( <= 1 )
return 1 ;
else
{
fibArray[ 0 ] = 1 ;
fibArray[ 1 ] = 1 ;
for ( int i = 2 ; i < 25 ; i++ )
fibArray[ i ] = ( fib ( n - 1 ) + ( fib ( n - 2 ) ) ) ;
}
return fibArray[ n ] ;
}
Nevermind, I got it working. Didn't think to use an array; well I thought about it, but didn't think it would make the problem easier. Here's my fibonacci sequence, written iteratively.
#include <iostream>
using namespace std ;
int main ( )
{
int fibArray[25] ; //max fib number
fibArray[0] = 1 ;
fibArray[1] = 1 ;
for ( int i = 2 ; i < 25 ; i ++ )
fibArray[ i ] = fibArray[ i - 1 ] + fibArray[ i - 2 ] ;
cout << fibArray[4] << "\t" << fibArray[7] << "\t" << fibArray[24] << endl ;
return 0 ;
}
Hey guys,
I'm supposed to write a program that will calculate the Nth fibonacci number, without using recursion.
I have the recursion problem written already, but am having a hard time doing the iterative one.
here's my recursion function:
int fib ( int n )
{
if ( n <= 1 )
return 1 ;
else
return ( fib ( n - 1 ) + ( fib ( n - 2 ) ) ) ;
}
any help with getting me started on the iterative one?
Hey guys,
we were given an opportunity for extra credit in my OOP class. We're going over recursion and my prof said if we could do a project using recursion and do another useing iterative statments, and time them, we would be given extra cred.
Is there a way to call the system clock at the begining of the loop and at the end; then subtract the 1st from the 2nd? Is there an easier way than this?
that's awesome, why are you fasting?
I'm getting ready to drink more bottled water.
bottled water.
Public Class videoBonanzaForm
Dim videoBonanza(,) As String = {{"Comedy", "Aisle 1"}, {"Drama", "Aisle 2"}, {"Action", "Aisle 3"}, _
{"Sci-Fi", "Aisle 4"}, {"Horror", "Aisle 5"}, {"New Releases", "Back Wall"}}
Private Sub videoBonanzaForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub searchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchButton.Click
If categoriesListBox.SelectedIndex = -1 Then
MessageBox.Show("No Category Selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Else
aisleLabel.Text = videoBonanza(categoriesListBox.SelectedIndex, categoriesListBox.SelectedIndex)
End If
End Sub
End Class
I get an error at the Else statement during run time. Why can I not access the element this way?
sierra mist.
I have a question on my handout for class that says:
Justify / refute the statement that theese declarations are equivalent.
double speed[1] ;
double speed;
My guess was they are the same, since, even though speed[1] is an array, it is the same size of just speed.
Am I wrong?
still sunflower seeds.
Awesome, it's working great! I need to put some test code in main for my other functions, but I don't see them being a problem! Thanks a bunch!
Marking as solved.
so i do cin.ignore ( '\n' ) where?
Also you can put the initialisation in the initialisation list:
Student::Student ( string sName , int numC , string cList[ ] ) : name ( sName ) , numClass ( numC ), classList( new string [numClass] ) { for ( int i = 0 ; i < numClass ; i++ ) classList[ i ] = cList[ i ] ; }
Might as well use it when you can.
oh ok, didn't know you could do that. Thanks, I'll add that in now.
void Student::input ( )
{
cout << "This program reads a student name and the number & name of the classes.\n" ;
cout << "Enter the student name: " << flush ;
getline ( cin , name , '\n' ) ;
cout << "Enter the number of classes: " << flush ;
cin >> numClass ;
cout << "Enter " << numClass << " classes, each followed by pressing 'Enter':\n" ;
classList = new string [ numClass ] ;
for ( int i = 0 ; i < numClass ; i++ )
getline( cin , classList [ i ] ) ;
}
This skips the first iteration of the for loop.
It starts asking for classes, and if I put 4 as numClass it stops letting me input classes at 3. Here's a sample output:
This program reads a student name and the number & name of the classes.
Enter the student name: Matt
Enter the number of classes: 4
Enter 4 classes, each followed by pressing 'Enter':
History
Math
Science
Outputting student data for: Matt
1.
2. History
3. Math
4. Science
Outputting student data for: Caleb
1. Cisco
2. C++
3. Economics
4. NV.NET
5. C#
Press any key to continue . . .
ahhh! excellent!
Alright, got all the syntax errors out, but I'm getting a runtime error.
Here's the full code.
//File: prob4.h
#pragma once
//header files + efficiency
#include <string>
#include <iostream>
using std::cin ;
using std::cout ;
using std::flush ;
using std::endl ;
using std::string ;
typedef string * strPtr ;
//Student Class
// stores the name of the student, number of classes,
// and the names of classes taken. Functions provided
// for accessing and mutating the data.
class Student
{
public:
Student ( ) ; //default ctor
Student ( string sName , int numC , string cList[ ] ) ; //parameterized ctor
Student ( Student & cpy ) ; //copy ctor
~Student ( ) ; //dtor
Student operator = ( const Student & rtSide ) ;
void input ( ) ; //input data from user
void output ( ) ; //output data
void resData ( ) ; //reset numClass and classList[]
private:
int numClass ;
string name ;
strPtr classList ;
} ;
#include "prob4.h"
int main ( )
{
string s2Classes[] = { "Cisco" , "C++" , "Economics" , "NV.NET" , "C#" } ;
Student s1 ;
Student s2 ( "Caleb" , 5 , s2Classes ) ;
s1.input ( ) ;
s1.output ( ) ;
s2.output ( ) ;
return 0 ;
}
//File: prob4.func
//header file
#include "prob4.h"
Student::Student ( ) : numClass ( 4 ) , name ( "John Doe" ) , classList ( NULL )
{ /*Body intentionally empty*/ }
Student::Student ( string sName , …
sweet thanks.
I get
error C2143: syntax error : missing ';' before '*'[/code] at the typedef line (and every other line with the word 'string').
...
//File: prob4.h
#pragma once
//header files + efficiency
#include <string>
#include <iostream>
using std::cin ;
using std::cout ;
using std::endl ;
typedef string * strPtr ;
//Student Class
// stores the name of the student, number of classes,
// and the names of classes taken. Functions provided
// for accessing and mutating the data.
class Student
{
public:
Student ( ) ; //default ctor
Student ( string sName , int numC , string cList[ ] ) ; //parameterized ctor
Student ( Student & cpy ) ; //copy ctor
~Student ( ) ; //dtor
Student operator = ( const Student & rtSide ) ;
void input ( ) ; //input data from user
void output ( ) ; //output data
void resData ( ) ; //reset numClass and classList[]
private:
int numClass ;
string name ;
strPtr classList ;
} ;
sunflower seeds and pepsi, with an occasional sip of bottled water
sunflower seeds and bottled water
could you give me an example?
Hey guys, Could you tell me what is wrong with this part of my code:
#include <iostream>
using namespace std ;
class TwoD
{
public:
TwoD ( ) ;
TwoD ( int , int ) ;
private:
int *m ;
int d1 ;
int d2 ;
};
int main ( )
{
int d1 , d2 , j , k ;
cout << "Enter row and column dimensions: " << flush ;
cin >> d1 >> d2 ;
TwoD m1 ( d1 , d2 ) ;
cout << Enter " << d2 << " rows of " << d2 << " doubles each\n"
for ( k = 0 ; k < d1 ; k++ )
for ( j = 0 ; j < d2 ; j++ )
cin >> m1 ( k , j ) ;
...
return 0 ;
}
I get an error that says
Term does not evaluate to a function taking 2 arguments
This happens at the last line of the code you see.
McDonalds beacon/egg/cheese bagel.
nevermind, fixed it.
I had put
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
in PrintDocument1_PrintPage instead of printButton_Click.
here's my printing code:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim printlinestring As String
Dim horizontalPrintLocationSingle As Single
Dim verticalPrintLocationSingle As Single
Dim printfont As New Font("arial", 12)
Dim lineheightsingle As Single = printfont.GetHeight
horizontalPrintLocationSingle = e.MarginBounds.Left
verticalPrintLocationSingle = e.MarginBounds.Top
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
e.Graphics.DrawString("Caleb Tote", printfont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
verticalPrintLocationSingle += lineheightsingle * 2
For listindexinteger As Integer = 0 To typeComboBox.Items.Count - 1
printlinestring = typeComboBox.Items(listindexinteger)
e.Graphics.DrawString(printlinestring, printfont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
verticalPrintLocationSingle += lineheightsingle
Next
End Sub
I get an error at run time that says InvalidOperationException was unhandled by user code at this line:
PrintPreviewDialog1.ShowDialog()
Any help?
Thanks!
Just ate meatballs and noodles, half of a small salad, and split a snickers icecream sandwich with chrstina :)
yeah good idea. He's pretty understanding about late work; and considering we haven't finished the chapter lectures, I think he'll give us a couple days longer.
thanks
we use 3D imaging that takes two images and (with special glasses) "tricks" your brain into thinkings it's one 3D image. We use it to calculate the size of coal fields; much more effecient than sending out a surveying crew. Just fly over, take a few pictures, bring it up on the computer, and map it out.
Oh my bad; I meant I am completely lost on what the problem is asking me to do. How should the polynomials be input?
That way you wouldn't have to worry about dynamic arrays. 100 would of course be the largest exponent of x in your poly class.
we have to use dynamic arrays for this particular problem.
I'm still completely lost; could you provide an example of what would be input/output in a test run?
I figured we had more hard core halo3 players than this. =\
Maybe not the best place for this poll.
> I'll be paying $25 for a team tournament towards the end of the month. It is for charity though...
that's awesome. $25? You get food or anything?
what is this doing:
// a * x^b
public Polynomial(int a, int b) {
coef = new int[b+1];
coef = a;
deg = degree();
}
// return the degree of this polynomial (0 for the zero polynomial)
public int degree() {
int d = 0;
for (int i = 0; i < coef.length; i++)
if (coef != 0) d = i;
return d;
}
Hey everyone,
I have an assignment to work on and it's a bit confusing.
Here's the problem:
Using dynamic arrays, implement a polynomial calss with polynomial additions, subtraction, and multiplication.
Discussion: A variable in a polynomial does nothing but act as a placeholder for the coefficients. Hence, the only interesting thing about polynomials is the array of coefficients and the corresponding exponent. Think about the polynomial
x*x*x + x + 1
Where is the term in x*x? One simple way to implement the polynomial class is to use an array of doubles to store the coeficients. The index of the array is the exponent of the corresponding term. If a term is missing, then it simply has a zero coefficient. There are techniques for representing polynomials of high degree with many missing terms. These use so-called sparse matrix techniques. Unless you already know these techniques, or learn very quickly, don't use these techniques.
Provide a default constructor, a copy constructor, and a parameterized constructor that enables an arbitrary polynomial to be constrcuted.
Supply an overloaded operator = and a desctructor.
Provide these operations:
polynomial + polynomial, constant + polynomial, polynomial + constant,
polynomial - polynomial, constant - polynomial, polynomial - constant,
polynomial * polynomial, constant * polynomial, polynomial * constantSupply functions to assign and extract coefficients, indexed by exponent.
Supply a function to evaluate the polynomial at a value of type double.
You should decide whether to implement these functions as …
The biggest crowd drawer is cash; we couldn't possibly offer $200 to the winning team without charging admission.
Hey guys,
We're getting ready to start planning for our Halo3 tournament. It's going to be double elimination, with 8 teams of 4 in Team Slayer to 50.
I'm curious as to what price to charge for tournament players.
I told Christina we had planned on $5 for entry and an extra $10 to join the tournament. 1st place gets $200 (+ other misc. swag). She mentioned this may be too steep, and $5 extra would be better.
What do you think?
Where is that thread about the huge star that was like 99999999x larger than our sun?
just ate italian cheese bread :)
Hey guys, I am in desperate need of a monitor with the following specs:
* 21” or larger CRT
* Horizontal Frequency = 30-115 KHz or greater
* Vertical Frequency = 50-160 Hz or greater
* Recommended resolution of 1280 x 1024 @ 120 Hz / True Color
* Required resolution of 1280 x 1024 @ 100 Hz / True Color (preferably 100Hz+)
Can someone help me out? It can't be the ViewSonic G22fb or whatever; we've had 3 of those go bad in the past 6 months.