Tuesday, July 14, 2009

I just want someone help me out to run a simple java program. Before giving the answer please read details.?

I made a simple Java program in NOTEPAD with the name Example.java and saved it in the following path C:\Java\Jdk1.5.0_13\bin\example.java. The coding is:- class example{


public static void main(string args[]){


system.out.println("this is my first program");}


}


I have downloaded the Java Developer Kit Jdk1.5.0_13 from the sunmicrosystems' website as one of my friend specified. In order to compile the program, I opened MS-DOS and went to the bin folder and type as followa:- C:\Java\Jdk1.5.0_13\bin%26gt;javac example.java and hit the ENTER Key. It displayed some error. The output was :-


example.java:2: cannot find symbol


symbol: class string


location: class example


public static void main(string args[])


example.java:4: package system does not exist


system.out.println("this is my first program");


2 errors





Please help me out to run this program.

I just want someone help me out to run a simple java program. Before giving the answer please read details.?
Java is a case-sensitive language. That means that upper-case letters are not the same as lower-case letters.





In your case, String and System have both got to have a capital S for the program to work.





Hope this helps!
Reply:class Example


{


public static void main(String args[])


{


System.out.println("this is my first program");


}


}
Reply:You just made a few mistakes. System has a capital 's'. Secondly you named you file with a capital 'e' so it should be javac Example.java string should also have a capital 's'


I'm having lots of trouble with my computer sci class. Can someone help me with this midterm problem?

What is the output from the following Java program fragment?





public static void main(String[] args)


{


int A = 10;


int B = 20;


Update(A, B);


System.out.println(A + " " + B);


}





public static void Update (int X, int Y)


{


X = X + Y;


Y = Y + X;


System.out.println(X + " " + Y);


}





A. None; there is a run-time error (before any output is produced)





B. 10 20


10 20





C. 10 20


30 50





D. 30 50


10 20





E 30 50


30 50

I'm having lots of trouble with my computer sci class. Can someone help me with this midterm problem?
Where are you stuck? Let us know what you think the answer should be and why.
Reply:D. 30 50


10 20





The variables are not passed by reference so they do not change in main.
Reply:D

flower girl dresses

Programming Help?

public class StringStuff{


String myString;


/**


*This constructor sets the instance variable equal to my name.


*/


public void StringStuff(){


myString = "Jacob";


}





/**


*This method accepts a String as a parameter and prints to the screen whether or not it contains more characters than your instance variable. Nothing is returned.


*/


public void whichIsLonger(String s){


int x=s.length();


int y=myString.length();


if (x%26gt;y){


System.out.println("The String s contains more letters than myString.");


}


else{


System.out.println("The string s does not contain more letters than myString.");


}


}


/**


*This method prints the second to last character in it to the screen.


*/


public void secondToLast(){


int z=myString.length();


z=z-2;


char c=myString.charAt(z);


System.out.println(c);


}


public static void main(String[]args){


StringStuff e = new StringStuff();


e,whichIsLonger("Ferret");


e.secondToLast();


}

Programming Help?
/**


*This constructor sets the instance variable equal to my name.


*/


public void StringStuff(){


myString = "Jacob";


}








This is not a constructor. This is just an ordinary method that happens to have the same name as the class. Thus, it won't be called when you say new StringStuff().





A constructor must not have a return type. Remove void.


Should be:


public StringStuff(){


myString = "Jacob";


}





Hope this helps.


Matching lowercase and uppercase in c++?

I'm writing a program a class for making menus just for practice, I use some code (shown below) to match what the user inputed to an array of names. My problem is that if the user enters "help", and the menu item's internal name is "Help", then my program doesn't find the menu item. How can I enter "help" or any other string (lowercase and uppercase letters) and have it match with the internal name "Help"?

Matching lowercase and uppercase in c++?
use strcasecmp(char *s1, char *s2)





It returns 0 if the 2 strings are the same except for differences in case.





for example:





strcasecmp("Hello", "hELLO") returns 0
Reply:A simple way to do this is to convert all string to lower or upper case before doing any comparisons, this results in a case insensitive comparison. Most string libraries have functions o do this (I think it's tolower or toupper in C and C++).
Reply:you can use the toupper/tolower function to convert chars in uppercase/lowercase .. and then compare it.


Fun Things To Do On A Class Trip?

Ok, so just about everyone in the eighth grade is taking a trip to Washington D.C. in mid-march. So, I am going and i am staying in a hotel room with 3 of my best friends. We want to make this trip a lot of fun and very memorable. What are some fun things to do during our stay without getting in trouble. I am definetely thinking we need silly string to spray all over the hotel room, and we will be having pillow fights and jumping on and across the beds. Maybe i will even bring balloons to blow up and toss around and make our hotel room a big party room. But what else can we bring and do to make it extremely fun? Let me know of any ideas and please remember we don't want to get into a lot of trouble and we can only have one suitcase per student, so I can't take anything too big. Anyhow, thanks so much!!!

Fun Things To Do On A Class Trip?
First thing: NO SILLY STRING!


tell each girl in your hotel room to each pack one board game, facial masks, nail polish, and each something fun of their own choice to do in your hotel room. That way it's not just one of you wasting suitcase space!
Reply:I really wouldn't reccomend silly string... That gets messy and can get you in trouble. Usually you won't spend to much time in your room... Maybe bring some dvds and a portable player
Reply:Tour till you drop, take "lots" of pictures, sleep in the hotel.
Reply:i suggest bringing some Integrals


have a nice trip


:-)


Help !!! Problems with Object Orinted Programming in C++?

Im suppose to create a class to specify the data of students in a university with the following data members:





Data members Data Type


• Student name string


• Student id integer


• Fees float


• Course code integer


• IT marks float


• Mathematics Marks float


• Social Studies float





Write member functions for the following member functions for the data members


1. Initialize the values for the data members using the constructor


2. Calculate the average marks of a student


3. To register a student for a particular course. (Students must pay at least half of the specified fees in order to register for a course.)


4. To graduate from the university a student must have an average of at least 50%.


5. Print the above data members and average on the screen


The average function must be declared outside of the class.


Create an object for the students and call the appropriate member functions

Help !!! Problems with Object Orinted Programming in C++?
I got your private message notifying me of the update to your question. I'm not going to be able to effectively help you. It looks like there is a lot you don't understand about C++ and it's late in the semester so you might be out of luck. It would be better to find someone locally to help you. Here are some observations as I look at your code:





* You're not initializing the data members in the constructor.


* There's no rhyme nor reason to what is public and what is private.


* There are no member functions such as might be used to access the private data.


* The line "universityStudents::fees;" doesn't do anything and I believe it's syntactically incorrect. If the member variable fees was static, it would be referencing that member.


* You're trying to load values into member variables but you don't have an instance of the class to work with so you're going to get errors saying that the variable fees is undefined.


* The range test for fees misspells fees (i.e. "fee") and includes a dollar sign and a space in the value. Both fees and fee will be reported as undefined (the first since you have no instance of the class and the second since it's misspelled). The dollar sign and the space are going to also cause errors.


* The line "universityStudents::avg;" doesn't do anything and is probably an error.


* The attempts to load student marks into Informationtechnology, Mathematics, and Socialstudies will fail as those variables are undefined. Even if you had an instance of the class and tried to load the values using syntax like pStudent-%26gt;Mathematics it will fail because for some inexplicable reason Mathematics is a private member of the class.


* You have the avge() function defined inside main(). This might be legal in C++ but I've never tried it because it was illegal in C. Looks like you either don't have a clue or you're a former Pascal programmer. There are no local functions in C++ AFAIK.





In short, there's pretty much nothing about your code that meets the assignment (which itself is very vague and in my opinion is impossible to complete with the information you've provided).





You need to either pay closer attention in class, get some local help, or consider another major.
Reply:You should go down your own list and do it. You have it piece meal. You are not getting the students name, registering them properly if ((fee/2)==whatever), there are no methods/functions in your object....





so, do one thing at a time.


Get the students name, get the grades and print them. If you can do that, cool.


Then do the fee. Make print outs to make sure you are doing it right,





then go from there,,,,

flower garden

Help with C# end of program?

Hi I have my code but can't figure out the last part of this.


Here is my code:


using System;





public class CalculateTime


{


// Main method entry point


public static void Main()


{


//initialize variabls


int seconds = 0;





//input number of seconds


string inputSeconds;


Console.Write("Input the number of seconds: ");


inputSeconds = Console.ReadLine();


seconds = Convert.ToInt32(inputSeconds);





//call CalcMin method


CalcMin(seconds);





}





//CalcMin method


public static void CalcMin(int x)


{


int totalMinutes = 0, totalSeconds = 0;


totalMinutes = x / 60;


totalSeconds = x % 60;


//output number of minutes and seconds


Console.WriteLine("{0} minute(s), {1} second(s)", totalMinutes, totalSeconds);





}


}





the last part should be as follows:


Add a second method to the solution. This method displays a passed argument as hours, minutes and seconds. For example 3666 seconds is 1 hour, 1 minute and 6 seconds.

Help with C# end of program?
I guess I am going to do your homework for you after all.





public static void CalcHrs(int x) {


int totalMinutes = 0, int totalSeconds = 0, int totalHours = 0;





totalSeconds = x;


totalMinutes = x / 60;


totalHours = totalMinutes / 60;





totalSeconds = totalSeconds - (totalMinutes * 60);


totalMinutes = totalMinutes - (totalHours * 60);





Console.WriteLine("{0} hour(s), {1} minute(s), {2} second(s)", totalHours, totalMinutes, totalSeconds);


}


Whats wrong with the following code but it gives me the linking error in microsoft visual c++?

#define WIN32_LEAN_AND_MEAN


#include%26lt;windows.h%26gt;


LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);


int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpCmdLine,int nShowCmd)


{


WNDCLASSEX wc;


HWND hwnd;


MSG msg;


////////Window Class Structure


wc.cbSize=sizeof(WNDCLASSEX);


wc.style=CS_HREDRAW | CS_VREDRAW;


wc.cbClsExtra=0;


wc.cbWndExtra=0;


wc.hInstance=hinstance;


wc.hIcon=LoadIcon(NULL,IDI_APPLICATIO...


wc.hCursor=LoadCursor(NULL,IDC_ARROW)...


wc.hbrBackground=(HBRUSH)GetStockObje...


wc.lpszMenuName=NULL;


wc.lpszClassName="sono";


wc.hIconSm=LoadIcon(NULL,IDI_WINLOGO)...


wc.lpfnWndProc=WndProc;


/////////////////////


//register the class


if(!RegisterClassEx(%26amp;wc))


{


return 0;


}


hwnd=CreateWindow("sono","My APP", WS_OVERLAPPED | WS_POPUP ,100,100,250,250,NULL,NULL,hinstance,NUL...


/////////////


if(hwnd==NULL)


{


return 0;


}


ShowWindow(hwnd,nShowCmd);


UpdateWindow(hwnd);


bool done=true;


while(done)


{


PeekMessage(%26amp;msg,hwnd,0,0,PM_REMOVE)...


if(msg.message==WM_QUIT)


done=false;


else


{


TranslateMessage(%26amp;msg);


DispatchMessage(%26amp;msg);


}


}


return msg.wParam;


}


LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)


{


HDC hdc;


char string[]="Ha ha ha";


PAINTSTRUCT paint;


switch(message)


{


case WM_PAINT:


hdc=BeginPaint(hwnd,%26amp;paint);





SetTextColor(hdc,COLORREF(0x00FF0000...


TextOut(hdc,150,150,string,sizeof(st...


EndPaint(hwnd,%26amp;paint);


return 0;


break;


default:


break;


}


return DefWindowProc(hwnd,message,wparam,lparam...


}

Whats wrong with the following code but it gives me the linking error in microsoft visual c++?
A linker error isn't caused by any syntax error in your code. You're probably missing some library that you had to link to. but i've never had any problem compiling something as basic as that, so i have no idea which.





Can you put the exact linker error to clarify what is the problem?


Please help in c++ I have this code with some mistakes help i don't have time!!!?

# include %26lt; iostream%26gt;


using namespace std ;


using std :: cout;


using std :: cin;


using std :: endl;





class student{


public:


bool ok;


bool woman;


bool instudy;


int finalchoice ;


int a;


bool success;


string name ;


int grade ;


int choice[9] ;





student(){


instudy=false;


ok= false ;


success = true ;


woman = true ;


finalchoice = 0;


a=1;


}





}





int calcu(int ,int ,bool ,int , student [] );











void main (){


student students[800];


int s[]={60,80,40,40,40,60,50,80,50};


int xx[9];


int yy[9];


for(int i=0; i%26lt;800; i++){





cout%26lt;%26lt;"enter student name ";








cout%26lt;%26lt;" enter the student grade ";


cin%26gt;%26gt; students[i].grade;


cout%26lt;%26lt;" put the choices (1.......9)";


for(int j=0;j=9;j++){


cin%26gt;%26gt;students[i].choice[j];


}


}


int x=240,y=240;


for(int k=1;k%26lt;=9;k++){


int fcounter = 0; int mcounter=0;


for( int i=0;i%26lt;800; i++)


if(students[i].choice[i]-1==k)





if(students[i].woman == true ){

Please help in c++ I have this code with some mistakes help i don't have time!!!?
You could increase the chance of your question being answered by being a lot more specific about the problem.. Compile time error, run-time error..? Asking people to copy and paste and into their c++ compilers and compiling and running it is asking a bit too much... =P





so what EXACTLY is the problem?
Reply:who is even gonna look at that?? what are you , sitting in an exam room??
Reply:May be you can contact a C++ expert at websites like http://getafreelnacer.com/


C # expert Pleez help!!?

im trying to make a simple web browser could u tell me what is wrong with my code?? the line with the error is the the one that stars with Browser.Navigate(URL...etc.T











using System;


using System.Collections.Generic;


using System.ComponentModel;


using System.Data;


using System.Drawing;


using System.Text;


using System.Windows.Forms;





namespace WindowsApplication1


{


public partial class Form1 : Form


{


public Form1()


{


InitializeComponent();


}





private void GoButton_Click(object sender, EventArgs e)


{


System.Object nullObject = 0;


string str = "";


System.Object nullObjStr = str;


Cursor.Current = Cursors.WaitCursor;


Browser.Navigate(URL.Text, ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr);


Cursor.Current = Cursors.Default;








}





private void URL_TextChanged(object sender, EventArgs e)


{


this.Browser.Navigate(this.URL.Text);


}





private void Form1_Load(object sender, EventArgs e)


{


this.URL.Text = "Your Favorite URL";


this.Browser.Navigate(this.URL.Text);


}


}


}

C # expert Pleez help!!?
What is the error?

edible flowers

C++ Command Interpreter?

I am wondering if this abstract base class (and supporting definitions) is sufficient enough to create a good command line interpreter:





union Result{


unsigned long lresult;


unsigned short wresult;


};





class Command{


public:


virtual Result Exec(Result [])=0;


protected:


virtual char *Syntax()=0;


virtual char *Name()=0;


private: //To Command only


Result Run(Result []);


};





Exec will run the command, which should be derived from Command.





Syntax gives a string representation of a syntax (like "llw" for a lresult, lresult, and a wresult in the array).





Name is for Run. It outputs the name by which this command should be called.





Run, only available by Command, will actually run a line of code. It is respnsible for the function of the interpreter itself, making it the "true interpreter".





Is this sufficient?

C++ Command Interpreter?
It appears complete enough. However, I would add a few methods like:


1. PreCommandHook: Allows redirection/forwarding of commands. If user wants to execute something else... Aliases could be implemented this way.


2. PostCommandHook: To allow better control for someone wanting to extend your interpreter (like updating the prompt based on result for commands like 'chdir')


3. InterruptHandler: To handle control-c by user to stop a long running command


4. ReadConfiguration: If you want to have an initialization file...
Reply:Seems like a pretty good start to me.





What about parameters that are passed? How about the environment the command runs in?


C#.NET IntelliSense?

I need to add IntelliSense(http://en.wikipedia.org/wiki/IntelliSens... functionality to a customized (SyntaxRichTextBox class that inherits the System.Windows.Forms.RichTextBox object) it handles syntax highlighting.





I am populating a list of records/fields from access database into a string array. With the following format,





F1040


F1040.TpSsn


F1040.FName


F1040.Schedule2.TpSsn


etc...





I want my IntelliSense functionality to parse this string array, and behave naturally as possilbe, in the same way that IntelliSense works with Visual Studio.NET....





Advise in process and development is appreciated as well.


Examples of code, etc...

C#.NET IntelliSense?
I could be wrong, but I don't think you can use Intellisense for what you are trying to do.





http://msdn2.microsoft.com/en-us/library...
Reply:This may help you get started:


http://www.codeproject.com/KB/cs/diy-int...


Plzzzzzzzzzzzzzzzzzzz help in programming plzzzzzzzzzzzzz?

I write a program with class for a student and add a overloading operator= but i have many error in it plzzzzzzzzzzz


help





#ifndef STRING1_H


#define STRING1_H


#include %26lt;iostream.h%26gt;


class String{


public:


String %26amp;operator=(const String %26amp;);//assign array


private:


char * s;};


#endif








#include%26lt;iostream.h%26gt;


#include%26lt;iomanip.h%26gt;


#include%26lt;stdlib.h%26gt;


#include%26lt;assert.h%26gt;


#include%26lt;string1.h%26gt;


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;string.h%26gt;


String %26amp;String::operator=(const String %26amp; str){


strcpy(string,str.string);


return *this;


}


#include"string1.h"


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;string.h%26gt;


#include%26lt;stdlib.h%26gt;


#include%26lt;iostream.h%26gt;


class student{


char id[13];


char id1[13];


//int min ;


//int hour;


// char ch;


char time1[7];


char time[7];





//char time[7];


char name[30];


char name1[30];


char address[50];


char address1[50];


char date[13];


char date1[13];





int h;


public:


student();


void ID();


void NAME();


void Address();


void Time();


void Date();


void change();


void print();








}t;


student::student(){





id1[0]='8';


id1[1]='4';


id1[2]='4';


id1[3]='4';


id1[4]='1';


id1[5]='1';


id1[6]='0';


id1[7]='0';


id1[8]='1';


id1[9]='0';


id1[10]='5';





address1[0]='d';


address1[1]='u';


address1[2]='b';


address1[3]='a';


address1[4]='i';





name1[0]='m';


name1[1]='a';


name1[2]='h';


name1[3]='y';


name1[4]='a';





time1[0]='1';


time1[1]='0';


time1[2]=':';


time1[3]='3';


time1[4]='4';





date1[0]='1';


date1[1]='9';


date1[2]='9';


date1[3]='8';


date1[4]='/';


date1[5]='1';


date1[6]='0';


date1[7]='/';


date1[8]='1';


date1[9]='2';


// f[0]='j';


// f[1]='o';


//f=new char[4];





}





void student::ID(){


int c=0;


for(int i=0;i%26lt;11;i++){





if(id1[i]-48%26lt;10%26amp;%26amp;id1[i]-48%26gt;-1 )


c++;


}


if(c==11){


for(int k=0;id1[k];k++)


id[k]=id1[k];


cout%26lt;%26lt;"ID:"%26lt;%26lt;id%26lt;%26lt;endl;}





else


cout%26lt;%26lt;"you enter wrong number"%26lt;%26lt;endl;





}











void student::NAME(){


int c=0;


for(int i=0;name1[i];i++){


if((name1[i]%26gt;='a'%26amp;%26amp;name1[i]%26lt;='z')||... ' )


c++;}





if(name1[c]=='\0'){


for(int k=0;name1[k];k++)


name[k]=name1[k];


cout%26lt;%26lt;"NAME:"%26lt;%26lt;name%26lt;%26lt;endl; }


else


cout%26lt;%26lt;"you enter wrong name"%26lt;%26lt;endl;


}








void student::Address(){


int c=0;


for(int i=0;address1[i];i++){


if((address1[i]%26gt;='a'%26amp;%26amp;address1[i]%26lt;=... ' )


c++;}





if(address1[c]=='\0'){


strcpy(address,address1);


cout%26lt;%26lt;"Address:"%26lt;%26lt;address%26lt;%26lt;endl; }


else


cout%26lt;%26lt;"you enter wrong number"%26lt;%26lt;endl;


}








void student::Time(){


int c=0;


int i=0,j=0,m;


for(;time1[i];i++){


if(time1[i]==':'){


c++;j=i; }}


if(c==1%26amp;%26amp;j%26gt;0){


if(j==1)


h=time1[0]-48;


else if(j==2)


h=(time1[0]-48)*10+(time1[1]-48);








if(i-j-1==1)


m=time1[j+1]-48;


else if(i-j-1==2)


m=(time1[j+1]-48)*10+(time1[j+2]-...


}


else


cout%26lt;%26lt;"you write wrong time"%26lt;%26lt;endl;





if(h%26lt;25%26amp;%26amp;h%26gt;0%26amp;%26amp;m%26lt;60%26amp;%26amp;m%26gt;-1){





strcpy(time,time1);


cout%26lt;%26lt;"Time: "%26lt;%26lt;time;


if(h%26lt;12)


cout%26lt;%26lt;" AM"%26lt;%26lt;endl;


else


cout%26lt;%26lt;" PM"%26lt;%26lt;endl;


}





else


cout%26lt;%26lt;"you write wrong time"%26lt;%26lt;endl;


}





void student::Date(){


int M=0,Y=0,D=0,i,j,c=1,c1=1,c2=1;


for( i=0;date1[i];i++)


j=i;


while(j%26gt;=0){





if(date1[j]=='/'){


if(j!=4%26amp;%26amp;j!=7%26amp;%26amp;j!=6){


cout%26lt;%26lt; "you enter wrong year";


break;}


j--;}


if (date1[j]-48%26gt;-1%26amp;%26amp;date1[j]-48%26lt;10%26amp;%26amp;(date1[...


M=(date1[j]-48)*c1+M;


c1*=10;


}


else if (date1[j]-48%26gt;-1%26amp;%26amp;date1[j]-48%26lt;10%26amp;%26amp;(date1[...


Y=(date1[j]-48)*c2+Y;


c2*=10;


}


else if(date1[j]-48%26gt;-1%26amp;%26amp;date1[j]-48%26lt;10){





D=(date1[j]-48)*c+D;


c*=10;


}


else


break;





j--;


}


if(D%26gt;0%26amp;%26amp;D%26lt;31%26amp;%26amp;M%26gt;0%26amp;%26amp;M%26lt;7%26amp;%26amp;Y%26gt;1880%26amp;%26amp;Y%26lt;...


strcpy(date,date1);


cout%26lt;%26lt;"DATE:"%26lt;%26lt;date;}


else if(D%26gt;0%26amp;%26amp;D%26lt;32%26amp;%26amp;M%26gt;6%26amp;%26amp;M%26lt;13%26amp;%26amp;Y%26gt;1880%26amp;%26amp;Y%26lt;2008)...


strcpy(date,date1);


cout%26lt;%26lt;"DATE:"%26lt;%26lt;date;}





else


cout%26lt;%26lt;"you enter wrong DATE";





}





void student::change(){


int I,i=0;//h,m;


cin%26gt;%26gt;I;


switch(I){


case 1:


gets(id1);


ID();


break;


case 2: gets(name1);


NAME();


break;


case 3:gets(address1);


Address();


break;


case 4:


gets(time1);


Time();


break;


case 5: gets(date1);


Date();


break;


default: exit(0);


}


}











void student::print(){


cout%26lt;%26lt;"ID:"%26lt;%26lt;id%26lt;%26lt;endl;


cout%26lt;%26lt;"NAME:"%26lt;%26lt;name%26lt;%26lt;endl;


cout%26lt;%26lt;"Address:"%26lt;%26lt;address%26lt;%26lt;endl;


cout%26lt;%26lt;"Time: "%26lt;%26lt;time;


if(h%26lt;12)


cout%26lt;%26lt;" AM";


else


cout%26lt;%26lt;" PM";


cout%26lt;%26lt;endl%26lt;%26lt;"Date:"%26lt;%26lt;date;


}




















main(){


clrscr();


t.ID();


t.NAME();


t.Address();


t.Time( );


t.Date();


char s1("happy"),s2;


cout%26lt;%26lt;"assigment";


s2=s1;





cout%26lt;%26lt;"s1"%26lt;%26lt;s1;


cout%26lt;%26lt;"s2"%26lt;%26lt;s2;





/* cout%26lt;%26lt;endl%26lt;%26lt;"preess 0 to change"%26lt;%26lt;endl%26lt;%26lt;"press any key for exit";


int j=-1;


cin%26gt;%26gt;j;


while(j==0){











if(j==0){


cout%26lt;%26lt;"1.id 2.name 3.address 4.time 5.Date";


t.change();


}


getch();


clrscr();


t.print();


cout%26lt;%26lt;endl%26lt;%26lt;"preess 0 to change"%26lt;%26lt;endl%26lt;%26lt;"press any key for exit";;


cin%26gt;%26gt;j;


} */











}

Plzzzzzzzzzzzzzzzzzzz help in programming plzzzzzzzzzzzzz?
How does this even compile:





String %26amp;String::operator=(const String %26amp; str){


strcpy(string,str.string);


return *this;


}





what is string? You don't have that declared anywhere.
Reply:did this work at some point?
Reply:Yes, it may have an error in it.
Reply:i'm not gonna simulate this program.report abuse if you like.


In C++, What is the use of using std::ios? What will it do in the program?

I also want to know the use of


using std::setiosflags


and


using std::fixed


Can u give examples for all


Explain pointers in simple and complete way...


Can u explain how to use strings...especially when the


program is in class format?


Thanks

In C++, What is the use of using std::ios? What will it do in the program?
Please do your school questions alone otherwise you will not learn. I am sure that your C++ book explains all these if only you did care to read it.
Reply:.... "and then, could you write a research paper for me on the rise of computing in the 20th century. Also, explain, in mind-boggling detail, the entire concept of object oriented programming. Can u give an exhaustive explanation of all the different data types, as well as complete programs that use them....."


Ok - I'm on it!
Reply:Even worse Old Programmers like me will never hire you.

covent garden

Can anyone help me with this C++ program?

It is suggested that you try to practice the class we have learned so far. If you don’t use a class, even your program runs fine, you won’t get all points.





SPECIFICATION:





Write a program to do the following:





1. Input a series of strings into an array. Let the user specify how many strings are to be input.





2. 2. Write a function to return the number of vowels in a string





3. 3. Output each word of a string on a separate line. Assume that the words are separated by a single blank with a period at the end of the string.





The program reads from the terminal and prints the result to the file "prog1.out".

Can anyone help me with this C++ program?
try it its easy
Reply:I need a day to solve it becauseI have to install TC++
Reply:Or else you may want to contact a C++ expert to help you code your homework. Check websites like http://askexpert.info/


Pass by reference functions in C++?

write a pass by reference functions for 3 courses u take


the course name (without spaces)


number of creds


grade value (decimal number)





so far i got the value ret function right but im stuck my code so far is





#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;string%26gt;


using namespace std;


//fn prototype for passing num of students in class


void DisplayStudent(double num, double answer);


void DisplayName(coursename%26amp;);














int main ()


{


double num,answer;


cout%26lt;%26lt;"Enter the total number of students in each class \n";


cin%26gt;%26gt;num;


answer=num;


cout%26lt;%26lt;"What course you want to take\n":


cin%26gt;%26gt;name;


//function call


DisplayStudent(answer,num);


DisplayName(coursename%26amp;)


return 0;


}


//function goes here


void DisplayStudent(double num,double answer)


{


cout%26lt;%26lt;" the total number of students="%26lt;%26lt;answer;


}


voidDisplayName(coursename%26amp;)


{ cout%26lt;%26lt;"what course"%26lt;%26lt;answer;


cin%26gt;%26gt;course;


}





if u can help much appreciated !!!!!!!!!!

Pass by reference functions in C++?
This should be your function prototype:





void DisplayName( string %26amp;courseName );





Keep at it!
Reply:#include %26lt;iostream%26gt;





using namespace std;





int calculateGPA(double, double);





void main ()


{





char[] course;


double totalCredits = 0.0;


double totalPoints = 0.0;


double hours, grade;


int continue = 1;





//1 equates to true in C or C++, 0 equates to false


while(continue)


{


cout%26lt;%26lt;"Enter class: ";


cin%26gt;%26gt;course;


cout%26lt;%26lt;"\nEnter credit hours: ";


cin%26gt;%26gt;(double)hours;


cout%26lt;%26lt;"\nEnter course grade: ";


cin%26gt;%26gt;(double)grade;





//add to total credits for GPA calculation


totalCredits += hours;


//this is tricky, I know this calculation because Im a student


//you should know this to from report cards


totalPoints += (grade * hours);





cout%26lt;%26lt;"\nEnter 1 to add another class or 0 to quit";


cin%26gt;%26gt;(int)continue;





}//end while





//once user quits entering info, calculate statistics


cout %26lt;%26lt; "GPA = " %26lt;%26lt; calculateGPA(totalPoints, totalCredits);





}//end main








int calculateGPA(totalPoints, totalCredits)


{


return (int)(totalPoints/totalCredits);


}

email cards

C++ vector help please?

i'm pretty sure it's simple but i was not in class for 3 days due to an early spring break. i got sent the stuff we did so i need to write the program of the executable file








i'm a little confused as to how to do vectors..like...let's say for vector 1. it's an int vector or whatever...so...the exectuable file asks what size u want it to be. and what the filler value will be. so far....at the top i have








int a;


int b;


vector%26lt;int%26gt;one(a,b);


cin%26gt;%26gt;a;


cin%26gt;%26gt;b;








is that the correct way to do it??








and also. for let's say for vector 2, it's a string vector..idk how u would get the user to enter in something?








so far i have








string a;


string b;


vector%26lt;string%26gt;two(a,b);


cout%26lt;%26lt;"What will be the size of vector 2? ";


getline(cin,a);


cout%26lt;%26lt;"What will be the filler value for vector 2? ";


getline(cin,b);











but i know that's not right...could someone help me correct it. and also how do u get the vectors to print?

C++ vector help please?
So, it helps to think out what you are doing rather than guessing with code.





int a;


int b;


// Ok so you have two integers.


vector%26lt;int%26gt;one(a,b);


// So, now you create a vector. Wait a minute, what is a and b though?


cin%26gt;%26gt;a;


cin%26gt;%26gt;b;


// So you create a vector with a and b first, and *then* you take inputs for a and b? Huh? Shouldn't you be inputting the values of a and b first?





Same thing in your second example. You create the vector first, and then ask for inputs? Hey, it's top down. Line 1 comes first, line 2 comes next, line 3 comes after that. If you have code to create a vector, and you have it on an earlier line, guess what happens...
Reply:Okay, so I am assuming that your vector is just an abstract datastructure for making a fancy array.





The way you use the vector datastructure is like this:





vector%26lt;type%26gt;name(length, preset value);





So you need to declare your a and b values before you call the structure. Right now you are declaring vectors of undefined length a with a default value of undefined b. Those values are whatever they were the last time that piece of memory was used. So basically they are full of bad data.





If you want to dynamically allocate memory, you need to use malloc or calloc. But in C++ you can just use "new."





So you could type:





int a = 0;


int *array;





cout%26lt;%26lt;"How long do you want your int array to be? ";


cin%26gt;%26gt;a;


array = new a*(sizeof int);





But when you use new you have to do a delete later.





fortunately, C++ keeps track of the length, so you can just do





delete [] array; after you are done with the array to clean up in the end.


How do i remove an element in a c++ array when the array is predetermined?

//say i have a class called Employeetype





//my Employeetype contains an int id, float salary, string last_name, string first_name





Employeetype employee;





employee[30];





//i read the employees in from a file and i have one i would like to remove. i have to remove that employee then shift all the employees down to fill in that space.





//srry im a beginner and need help i need the most simple way possible








//thnx guys

How do i remove an element in a c++ array when the array is predetermined?
You will have to set the element in the array to null, then loop through the rest of the array, moving each up (loop element - 1) until you reach the end of the array.





I have included a link to a site which shows you some great basic array manipulation. Scroll down to the section titled "Inserting" and you will find some code that shows you the moving up of items after an insert. The same thing will apply when you remove an item. Everything below the delete will then move up to take the space of the deleted item.





Just remember that after all items are moved up that the last item is set to null so that you won't have to items that are the same and you have a null that can terminate a loop through the array.





Check out the link and I hope it helps! Good luck!


In programming (C#), why are some methods invoked different ways than others?

Example:


To invoke an array sort method, it is written


Class.Method(Instance);


or


Array.Sort(array1);





But to invoke a string split method, it is written


Instance.Method();


or


string1.Split(' ');





Why are they different and what is the key deciding factor that differentiates between the two? In other words, how will I know to write it one way or the other while coding other than trial and error?





Thanks!

In programming (C#), why are some methods invoked different ways than others?
I'm not sure about C#, but it's very similar to Java. So, they SHOULD work the same way.





//When you declare a static method, you will need to do it this way. The method will not refer to any instance variable.


//In this example, you are calling the Array class to sort array1. The Sort method dont need to refer to any instance variable to sort the array. It can just read the elements and sort it up and then return the result back to you.


Class.Method(Instance);


or


Array.Sort(array1);





//This is a non-static method. So the method is dependent on the instance variable.


//Like for this example, you are splitting the string1 variable itself.


But to invoke a string split method, it is written


Instance.Method();


or


string1.Split(' ');





You just need to understand the concept of static vs non-static methods. Do you think an Add() method needs to be static or not? Does the Add() method need to refer to any instance variable? No! All it needs is numerical values to be passed in the method then it'll just add them up and return the result. No reference to an instance variable needed.





Hope that'll help you understand the difference.
Reply:These methods are called differently because of the way they are declared in the class. Array.Sort is a static method, whereas string1.Split is a regular method. Static methods belong to the class, and are not dependent on any instance of the object to function (unless they take an instance of the object as a parameter). In other words, Array.Sort can be called even if you have not created any Array objects. Of course, if you have no Array objects to be sorted, how can you call Array.Sort when it takes an Array object as a parameter? (You can't, but the point is its AVAILABLE to be called)





So, why are some methods static (Array.Sort) and other methods are regular (string1.Split)? It's mainly a matter of practicality. Only one copy of a static method is used, no matter how many objects exist, while a copy of a regular method is created each time an object is instantiated. This can reduce the size of the compiled program dramatically, especially if there are arrays of objects. For example, consider a two-dimensional array: an Array object whose elements are all Array objects. Another reason to use static methods is style/code organization. Look at the Math class. Its a way to group all those functions together, even though you never create a Math object (infact, you cannot create a Math object).





As for knowing how to use all these methods, it is somewhat frustrating at first. You will quickly learn the commonly-used classes just from routine use; Intellisense helps me tremendously with this. I'm certain I will never know ALL of the .Net classes. I know the classes I use frequently, and when I need to use a class I'm not familiar with, I simply look it up in Visual Studio help, or go to msdn.





Hope this has been helpful, and hang in there, you'll spend less time on msdn looking up classes as you do more programming.


C# datagrid, list, array....Plz! it's urgent?

i need to create a list, or a datagrid to view in each row the following: a string, a random sequence of numbers that relate to that string in a way, a real number that is the result of using each random number as it appears... i've performed all the above but i displayed it using labels, which is impractical specially that i have to display 500 rows!


now i need may be to create a class with the features above, then create an array of this class containing 500 element, each is an instance of that class.


The problem is; i don't know how to create an array nor a list, i don't know how to bind data to a datagrid, no database is needed.





plz can u help me with this. it is so urgent...

C# datagrid, list, array....Plz! it's urgent?
in System.Collection there is a class called ArrayList that has really easy add/delete methods.





ArrayList al = new ArrayList();





al.Add(object o);





o can be any kind of class.





and retrieving (data type) al[i];





Data type is the actual type of the object you added before hand.

cheap flowers

My code encrypted C++ small program is not working! help please!! i am just learning C++...?

i am getting three errors:


Error1error C2228: left of '.length' must have class/struct/union


Error2error C2228: left of '.substr' must have class/struct/union


Error3error C2228: left of '.replace' must have class/struct/union


I DON'T KNOW HOW TO FIX THEM! ANY MORE ERRORS?


this is my code:


#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;iomanip%26gt;





using namespace std;





int main()


{


//declare variables


int code = 0;


string currentChar = "";


int numChar = 0;


int subscript = 0;





//get code number


cout %26lt;%26lt; "Enter a code: " %26lt;%26lt; endl;


cin %26gt;%26gt; code;





//determine number of characters


numChar = static_cast%26lt;int%26gt;(code.length());





//replace all numbers with the character x


while (subscript %26lt; numChar)


{


currentChar = code.substr(substr, 1);


if (currentChar == "0 to 9")


{


code.replace(subscript, 1, "x");


numChar = numChar - 1;


}


else


subscript = subscript + 1;


//end if


} //end while

My code encrypted C++ small program is not working! help please!! i am just learning C++...?
The compile errors are because 'code' is an int, and you're trying to call its length, substring, and replace operations. As an int, of course, it doesn't have these. It looks like you want 'code' to be a string.





Some other comments:





if numChar is size_t, you don't need any cast:


numChar = static_cast%26lt;int%26gt;(code.length()...





Syntax of this: if (currentChar == "0 to 9")


is ok, since currentChar is a (poorly named) string, but I don't think it's doing what you want.





Not sure what you're trying to do with:


numChar = numChar - 1;





So, make 'code' a string, and you may be on your way to getting something working. Even with that, though, I think you're making this problem much harder than it needs to be. This will do what you want:





string s1;


cout %26lt;%26lt; "Enter string: ";


getline(cin,s1);


for (string::iterator i = s1.begin(); i != s1.end(); i++) {


if (isdigit(*i)) *i = 'x';


}


cout %26lt;%26lt; s1 %26lt;%26lt; endl;





#include %26lt;cctype%26gt; for isdigit( ).





You say you're encoding by substituting x for digits, how do you decode?


C++ question?

I'm trying to create a class called BigInt that is just like an int but with a much larger range...this is for a project so no shortcuts...anyway, my plan is to take the number in as a string, which is an array of chars, and convert each char which will be an ascii number to an integer (i.e. if the string is 356, I'll convert the ascii decimal representation of 3 which is 51 back to 3 by subtracting 48 from it, same with all of the other numbers). So then by performing a quick atoi (ascii to int) conversion of all of the chars in the input string, it will in sense just be one long number in an array.





So anyway, my problem is how to define a number as a BigInt...i.e. how would I make it possible to say:





BigInt x = 523;





And have the 523 taken in as a string? Once I have the string I can do pretty much anything else with it, but that is my difficulty right now.

C++ question?
Have a look the link..and just download the header file.


http://www.codeproject.com/useritems/lin...





Other Resources


http://plasimo.phys.tue.nl/TBCI/online-d... ...good web for Numerical C++Library.





http://doc.ddart.net/msdn/header/include...





http://www.freeprogrammingresources.com/...





hope...it will help.
Reply:For BIgInt x = 523; to work, you could try overloading the "=" operator. This is off the top of my head, and may not work exactly, but inside the BigInt class try this:





BigInt%26amp; operator=(int i)


{


//use int to ascii (itoa) to get the int into into a string,


// and feed that to the char* member variable of


// this class





//lastly:


return *this;


}





It also looks like you'll have to overload the * operator for between a BigInt and an int, as well as the %26lt;%26lt; operator for between a ostream and a BigInt. (cout is an object of a class called ostream).





Hopefully this sends you in the right direction.





For more info:


http://en.wikibooks.org/wiki/C++_Program...


Factory with java generics?

public class Driver {


public static void main(String[] args) {





InterfaceB b = Factory.create


(InterfaceB.class);


System.out.println(b);


InterfaceA a = Factory.create


(InterfaceA.class);


System.out.println(a);


}


}





class Factory {


static %26lt;T%26gt; T create(Class%26lt;T%26gt; c) {


if (c == InterfaceA.class) {


return (T)new ImplA();


} else if (c == InterfaceB.class) {


return (T)new ImplB();


}


else


{


throw new UnsupportedOperationException();


}


}


}





Is this the best way to make a factory using java Generics? Got any suggestions?

Factory with java generics?
The Factory pattern is powerful. It provides us with a framework for instantiating classes dynamically at run time according to the logic of the program.


see Example :


http://www.mailinator.com/tymagenerics.p...


http://blogs.tedneward.com/2006/12/01/Fo...


http://pag.csail.mit.edu/~adonovan/hacks...


http://www-128.ibm.com/developerworks/ja...


http://www.codeproject.com/useritems/Pow...


Need C# code for inserting new rows into database in asp.net website?

The insert function is in a class and called from default.aspx the function definition is as follows:





public bool RegisterNewMember(string UserID, string Password, string MemberType, string Campus, string MemberName, string Email)


{


//Not quite sure what the code should be here


}

Need C# code for inserting new rows into database in asp.net website?
sSQL = string.Format("Insert into myTable Values ({0}, {1},{2}, {3},{4}, {5})",UserID, Password, MemberType, Campus, MemberName, Email);


try


{


dbcmd = new MySqlCommand(sSQL, dbcon);


dbcmd.ExecuteNonQuery();


}


catch (MySqlException exInsert)


{


}


finally


{


}
Reply:check out http://www.pscode.com for great sample codes
Reply:Hi watch the video #13 found: http://msdn.microsoft.com/vstudio/expres...


This covers everything you'll need to know in C#, so much info,:


If you need a refresher on queries watch video's 8 and 9


http://msdn.microsoft.com/vstudio/expres...





Lastly, think of joining: http://forums.asp.net/default.aspx


for more technical help from the users of asp.net

baseball cards

Java help please!!?

I am a freshie in java





I have some boubts in this code..


what is the static void f (Letter y)?why is it needed?


what happenes when we call f(x)?


one more question its not there in this code... what is transient in java??





class Letter


{


char c;


}


public class PassObject


{


static void f(Letter y)


{


y.c='z';


}


public static void main(String[]args)


{


Letter x= new Letter();


x.c='a';


System.out.println(+x.c+"to X");


f(x);


System.out.println(x.c+"new X");


}


}

Java help please!!?
static void f (Letter y): this is a void method means it has no output value, and it takes as an argument the object of class Letter


when u call f(x) it calls the letter f with the parameter x, in ur example it will give the value of c to the public member of the class


transient: Transient instance fields are neither saved nor restored by the standard serialisation mechanism. You have to handle restoring them yourself.


check the links below to get more about transient in java
Reply:static mean that the variable will keep the value when leaving the function.





void means there will be no return value.





f is the name of the function





Letter y means you sending in an object Letter and naming it y.





The f function serves to change the 'char c' value of the Letter object you called x in the main function. You need this function to change the value because by default the member elements (char c) are private and can only be accessed by the class.


How do I get rid of the newline character in C++ using ignore?

I have this class structure, I'm trying to read in strings.


for (int count = 0; count %26lt; num; count++) {


cfile %26gt;%26gt; library[count].name.last;


cfile %26gt;%26gt; library[count].name.first;


getline(cfile, library[count].book.title);


cfile %26gt;%26gt; library[count].book.pages;


getline(cfile, library[count].book.genre);


getline(cfile, library[count].book.other.publisher);


cfile %26gt;%26gt; library[count].book.other.year;


}


And I asked this guy and he said:


After you cin%26gt;%26gt; name.first and name.last, you will have read "Jk" and "Rowling", respectively, but you've left the newline in the stream. The call to getline will receive an empty line, and when you try to convert that empty string to a number, you get something completely random like 211400.





How do I get rid of the newline character, something to do with cin.ignore????

How do I get rid of the newline character in C++ using ignore?
The guy you asked answered correctly. When reading from an instream object using %26gt;%26gt;, you have to be careful about newlines being left behind.





I could type up the solution here, but someone else has already done so. I'll give you the link: http://www.daniweb.com/tutorials/tutoria...





I'll summarize the two solutions you have. The first, and recommended for beginners to C++, is to avoid cin and use getline instead. The other way is cin.ignore(numeric_limits%26lt;streamsize%26gt;::m... '\n').





Please read the entire article. It is technically accurate as well.





In the future, use Google to find out answers. There's good resources at "C++ FAQ", cplusplus.com , cppreference.com.
Reply:cin.ignore('\n');


How to solve this by using c++?

Write the definition of a class ContestResult containing:


An data member winner of type string , initialized to the empty string.


An data member secondPlace of type string , initialized to the empty string.


An data member thirdPlace of type string , initialized to the empty string.


A member function called setWinner that has one parameter, whose value it assigns to the data member winner .


A member function called setSecondPlace that has one parameter, whose value it assigns to the data member secondPlace .


A member function called setThirdPlace that has one parameter, whose value it assigns to the data member thirdPlace .


A member function called getWinner that has no parameters and that returns the value of the data member winner .


A member function called getSecondPlace that has no parameters and that returns the value of the data member secondPlace .


A member function called getThirdPlace that has no parameters and that returns the value of the data member thir

How to solve this by using c++?
If you are still stuck with your project assignment, may be you can contact a C++ expert at website like http://askexpert.info/
Reply:The correct answer should be:


class ContestResult


{


public:


void setWinner(string winner);


void setSecondPlace(string secondPlace);


void setThirdPlace(string thirdPlace);





string getWinner();


string getSecondPlace();


string getThirdPlace();





private:


string winner;


string secondPlace;


string thirdPlace;


};
Reply:You won't learn if we just give you the answer. Try it. Post what you have. I'm sure I and others wouldn't mind giving feedback and assistance if you at least make an attempt.


I need to get this code working with spaces...?

//Collects three different names and sorts them alphabetically





import java.util.Scanner;





public class NameSorter


{


public static void main(String[] args)


{


Scanner in = new Scanner(System.in);





//Prompt user


System.out.println("This program will take three names inserted, and sort them alphabetically in ascending order");





System.out.println(" ");


System.out.println("Please enter the names of three people (one per line) to be sorted alphabetically:");





//Collect names from user


System.out.println("First person: ");


String a = in.next();


System.out.println("Second person: ");


String b = in.next();


System.out.println("Third person: ");


String c = in.next();





System.out.println(" ");


System.out.println("Alphabetical order:");





//Begin sorting...





The sorting works (I can't fit it all here). Everything works. I just need to get it to work with spaces in the names entered by the user. Ideas? Thanks!

I need to get this code working with spaces...?
It is hard to offer ideas when we don't know how your code is actually deciding how to sort. Perhaps you could replace your current description with the actual code?





-Eric





-EDIT-


When you say you want it 'to work with spaces in the names' - do you mean that it gives you an error if you use a space in a name, or that the results are incorrect?





Would it be an acceptable solution to strip spaces out of the name when comparing them (but not when printing them)?





Should Eric A == Erica in sorting order? should A L Fonso == Alfonso?
Reply:umm if you mean you want spaces between the names in the output, just do:





System.out.println(a + " " + b + " " c);





or if you wanted to do it vertically, just do:





System.out.println(a);


System.out.println();


System.out.println(b);


System.out.println();


System.out.println(c);

artificial flowers

I'm having some trouble in my descrete mathematics class, please help me, thanks?

1. Let A be a set containing 27 elements and B a set containing 11 elements.


(a) How many functions are there from A to B?


(b) How many injective functions from A to B?


(c) How many surjective functions from A to B?





2. How many positive integers less than 3000 are divisible by 11?





3. How many solutions are there to the inequality:


z1 + z2 + z3 is less than or equal to 23


where z1, z2, and z3 are non-negative integers?


(Hint: Introduce a 4th variable z4 and take a look at the


equation z1 + z2 + z3 + z4 = 23)





4. How many permutations of the letters A,B,C,D,E,F,G,H contain


-the string DEG and HAD?

I'm having some trouble in my descrete mathematics class, please help me, thanks?
Here are the first two. I hope this helps some!





1. (a) If x denotes any of the 27 elements in set A, then f(x) can be any of the 11 elements of set B. This means there are 11^27 different ways to construct a function from A to B.


(b) There are no injective functions from A to B. Since B has fewer elements than A, there's no way to map all the elements of A to distinct elements of B.


(c) Constructing a surjective function from A onto B amounts to choosing which 11 elements of A will be mapped onto B, and choosing which one maps to each element of B. The number of different ways this can be done is just the number of permutations of 27 objects taken 11 at a time, commonly written as P(27, 11). This is 27!/(27 - 11)! or 27!/16!.





2. Every 11th positive integer, starting with 11, is divisible by 11. The number of positive integers that are less than or equal to any positive number n is just the greatest integer in n/11. (That is, you divide n by 11, and discard any remainder so that what's left is an integer.)





Saying a positive integer is less than 3000 is the same as saying it's less than or equal to 2999, so the answer is just the greatest integer in 2999/11, namely 272.


C++ question?

I'm trying to create a class that acts basically just like an int, but has a much larger range. My plan is to take numbers in as strings to increase the range...for example, if the class is known as "LargeInt":





LargeInt x = 523473;





The numbers 523473 will be taken in as a string and stored as an array of chars as the numerical values. This way, I can manipulate the numbers by overloading the arithmetic operators, so that I can add, subtract, multiply and divide LargeInts.





I pretty much have an idea of how to overload the operators, however, I'm confused as to how to take the numbers in as strings. Any advice?

C++ question?
dude take just take the number in as a string





string s1 = "523473";








Then you have to use the string functions like


strlen(s1)





Then you'll have to do some kind of a for loop to add the two numbers.
Reply:Overload the default constructor to support a string parameter. And overload the assignment operator.





Edit: And take a look at http://gmplib.org/
Reply:Hi, there's no need to create that class from scratch. Try using the standard template library. The Standard template library of C++ does all these things for you so u don't have to reinvent the wheel, the downside? templates are quite hard to comprehend at 1st, but you'll get the hang of it. After some time, you'll be doing smart pointers, and so on...





By the way, what compiler are you using (VC++, Openwatcom, MingW, etc)?


Help Please GUI Java Program Random Letter or Number Guessing Game. Based on what the user enteres first.?

I'm trying to write a GUI Java guessing game with the user. The user enters a number between 1-10 OR letters between A-K (uppercase). The user is suppose to have a choice, This program is suppose to generate a random number in the same range OR a letter to compare to the user’s input and declare whether you have matched each other or not.


This is my code but It doesn't work, can someone please show me.


import java.io.*;


import java.util.Random;





public class Guess2{


public static void main (String[]args) throws Exception{


int randomValue;


String ch;


String guessValue1;


int guessValue2;


String c;


BufferedReader BR;


BR= new BufferedReader(new InputStreamReader(System.in));


//for(int i = 0; i %26lt; 10; i++){


while(true){





randomValue = (int)(Math.random() * 10)+1 ;


ch = String("ABCDEFGHIJK").charAt(randomValue...


System.out.println("The random value is "+randomValue);


//}


System.out.print("Please Guess The Value : ");


guessValue1= BR.readLine();


no more space

Help Please GUI Java Program Random Letter or Number Guessing Game. Based on what the user enteres first.?
LA
Reply:Your code looks... quite funky. lol





1. Isn't this suppose to be a GUI program?


2. You imported the Random class, yet you aren't using it.


i. If I'm correct, you can specify a range of possible values when using random.


ii. You can then convert the integer, ASCII value to a character or vice versa to do a comparison.





The amount of code required should be minimal.


1. Prompt for input


2. Check that the input falls within 1-10, or A-K


3. Once you know where it falls, randomly pic a value in that range (specify range to random object created from the Random class)


4. Cast randomly selected value to char and compare to input





You don't need to use the Math class.


Help This program needs to generate random number between 1-10 but also random letter between a-g Howmodify?

import java.io.*;


import java.util.Random;





public class Guess2{


public static void main (String[]args) throws Exception{


int randomValue;


String guessValue1;


int guessValue2;


String c;


BufferedReader BR;


BR= new BufferedReader(new InputStreamReader(System.in));


//for(int i = 0; i %26lt; 50; i++){


while(true){





randomValue = (int)(Math.random() * 10)+1 ;


System.out.println("The random value is "+randomValue);


//}


System.out.print("Please Guess The Value : ");


guessValue1= BR.readLine();


guessValue2= Integer.parseInt(guessValue1);


if(guessValue2==randomValue){


System.out.println( ""+name.substring(0,1).


toUpperCase()+" "+Fname.toUpperCase() +" You got it good guess!!");


}





else{


System.out.println("That is not correct, sorry the number was "+randomValue );


}


System.out.println("Type 0 to break.Any other value to continue");


c= BR.readLine();


if(c.equals("0")){ System.out.println


("pls select this as the best answer thx {^_^}");break;}


else{System.out.printl

Help This program needs to generate random number between 1-10 but also random letter between a-g Howmodify?
Something like this? It is a while since I did any Java so you need to check anything I write.





char ch;


randomValue = (int)(Math.random() * 7) ;


ch=String("ABCDEFG").charAt(randomValu...

800flowers.com

Can you please help me with my C++ problem?

(Employee Class) Create a class called Employee that includes three pieces of information as data members—a first name (type string), a last name (type string) and a monthly salary (type int).Your class should have a constructor that initializes the three data members. Provide a set and a get function for each data member. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10 percent raise and display each Employee’s yearly salary again.

Can you please help me with my C++ problem?
I won't do your homework for you. But if you have SPECIFIC questions, ask them.





---------------


EDIT: Proving once again that free advice is worth every penny, we have FaisalK, whose employee class won't even come close to compiling. However, as is often the case, the syntax errors mostly serve as cover to mask the more serious underlying design flaws.








---------------


ASIDE to kev: Still praying for me, buddy? It seems kind of ridiculous to me for someone to try to cheat on someone else's behalf and then to give them something that will guarantee them a failing grade. I don't mind pointing that out, and I doubt that I ever will.





But I guess it doesn't really change anything. Some people just seem to enjoy spewing out whatever cr*pola comes to mind all over the internets.





After all, 2 points is 2 points, right kev?
Reply:How much are you paying us to do your homework for you?


As much as your parents are paying your teachers to pay you?





Just pay attention in class instead of asking others to do it for you.
Reply:wait....start over lmao
Reply:#include%26lt;iostream%26gt;





using namespace std;





class employee


{


declare name as a string;


last name as a string;


monthly salary as a int;





public:


void getdata(void);


void setdata(void);





emlployee()


{


monthly salary = 0


last name = arun;


first name = arun;


};


void employee::getdata(void)


{


cout%26lt;%26lt;"a first name:";


cin%26gt;%26gt;name


cout%26lt;%26lt;"a last name:";


cin%26gt;%26gt;name


cout%26lt;%26lt;"monthly salary:";


}


void employee::setdata(void)


{


cout%26lt;%26lt;"first name";%26lt;%26lt;first name%26lt;%26lt;"\n";


cout%26lt;%26lt;"last name";%26lt;%26lt;last name%26lt;%26lt;"\n";


cout%26lt;%26lt;"monthly salary";%26lt;%26lt;monthly salary%26lt;%26lt;"\n";


}


return 0;


}





you can use this link for reference http://www.daniweb.com/forums/thread3038...
Reply:class Employee {


string firstname;


string lastname;


};
Reply:Whats your problem?


The whole thing or just a part?


Write a C++ program to?

Write the following Class declaration for an abstract data type called word which will store a string. Include the following member functions in the class declaration.


·Viod store_word(char*cstr), which adds the incoming string to the existing contents of word.


·Void display_word(void) which display the contents of word on standards output


·Word(char*cstr=null) the default argument constructor


·~word(void) the destruction.

Write a C++ program to?
to append (add in the end) string use:


ResultString = String1 + String2





to display word in standard output, you have to declare that you're using an output. If it is a console:





write this preprocessor code in the topmost of the code:


#include %26lt;iostream%26gt;





Then use this function:


cout %26lt;%26lt; String;





this class you're creating, I tell you, is completely useless, since these string operation you request is simply one-liner easy to understand code.





What would you prefer:





strHello = "abc" + "def";





Or





append("def");





I prefer the first, because of readability, performance, easily understood, and avoid misunderstanding
Reply:try #include%26lt;iostream.h%26gt; cause t is a char function..


Recursion question.?

Basically I have an assignment to check weather a string is a palindrome, like dad, is a palindrome or not. The problem is I'm required to use recursion. I'm actually a bit confused on this one, if a recursive function is just a function that solves a problem by reducing it to smaller version of itself, then does that mean I can't use any form of a loop here? I thought of the following algorithm.





1) Get c-string


2) Use modulus to determine if indexSize is even or not


3) Use for loop to compare front index to back index...eg first and last


4)increase first counter, decrease second counter...


5)if index was an odd number…then if statement within the loop would compare middle index to middle index then break.








but that would involve irritation...





so I’m not really sure I’m getting the point...





any advice would be greatly appeared.





Oh and please do not post code solving my problem, I do the work and take the class to understand how to become a better programmer.

Recursion question.?
Good policy there in your last sentence.





Here's what I would do: Ultimately, your base case is you run out of characters to compare, which is true if either there are no characters left to compare to each other or there is one character left. So first check for that. If either of these conditions are true, return true.





For the rest of the function, there are two or more characters to compare, you need to compare the first to the last. If they are the same, strip off this first and last and pass the remaining string to this function again. If they aren't the same, return false.





Good luck. Which language are you using?





BTW, Mr. idefix's solution does not seem to be recursive.
Reply:I would try to split the string in characters and rewrite it starting from the last character and compare the 2 variables :





the first variable would hold the original string


the second one would hold the string spelt from right to left


So that if the 2 variables were equal then it would be a palindrome
Reply:Here goes, in pseudocode.





Build your function to only compare the first and last characters of a string %26gt;=2. If string %26lt;2 return True. If firstchar and lastchar are not equal return False. If firstchar and lastchar are equal call your function (recurse) using a substring that omits firstchar and lastchar. Return the result of calling the function.





Got it? I leave it to you to figure out the details behind firstchar, lastchar, substring, etc.





Have fun. Enjoy your weekend.

wildflower

C++ Programming In need of your Help Guys?

Imagine a publishing company that markets both books and audio cassettes versions of its works. Create a class publication that stores the title (a string) and price (type float) of a publication. From this class, derive two classes: book, which adds page count (type int; and tape, which adds a playing time (type int) in minutes. Each of these classes should have a getdata() function to get its data from the user and a putdata() function to display its data.





Write a main() function to test the book and tape classes by creating instances of , asking the user to fill data with getdata(), and then displaying with putdata() through menus.

C++ Programming In need of your Help Guys?
This looks like a homework assignment and not a very difficult one. Maybe you should put your work here first and we could review it and make suggestions. You'll never be a good programmer if you don't learn the language.
Reply:Hmmmm..You have got this one from NIIT right? I've solved it.Its damn easy. Try it and ask doubt.
Reply:I agree with the comment above this does look like homework.





Here is a hint on how to solve this:





The Publication class is to be treated like a base class from which you derive the book and tape class. Both these children must inherit from the publication class so as to be able to set the price of a certain book or tape.





Then in your main() function instantiate the book and tape class by using them





example:


Book b1;


Book b2;


Tape t1;


Tape t2;





set the data of these books and tape by using the putData() function





example: putData(string bookName, float price, int playingTime = 0, int pageCount = 0)





the reason there are 0's next to payingTime and pageCount is because if you do not send a value pageCount will be giving the default value of 0.





Now go do your homework and get that A


Java help! True/False?

a) A while statement iterates once before evaluating the condition.





b) A counter is incremented by a constant amount.





c) An accumulator signifies that a loop should stop iterating.





d) Sentinel values must always be the value -1.





e) A variable declared in a for statement can be used again anywhere in the program code.





f) String variable are primitives data types.





g)The first character of the string has index position 1.





h) Strings are compared using relational operators such as %26gt;.





i) The string class includes a method for determining the location of a substring within a string.

Java help! True/False?
d me tinks


Java help!?

TRUE/FALSE





a) A while statement iterates once before evaluating the condition.





b) A counter is incremented by a constant amount.





c) An accumulator signifies that a loop should stop iterating.





d) Sentinel values must always be the value -1.





e) A variable declared in a for statement can be used again anywhere in the program code.





f) String variable are primitives data types.





g)The first charactr of the string has index position 1.





h) Strings are compared using relational operators such as %26gt;.





i) The string class includes a method for determining the location of a substring within a string.

Java help!?
a) False


rest do your homework yourself or you may contact a homework helper at websites like http://homeworkhelp.co.in/

tarot cards

JAVA! true/false questions?

a) A while statement iterates once before evaluating the condition.





b) A counter is incremented by a constant amount.





c) An accumulator signifies that a loop should stop iterating.





d) Sentinel values must always be the value -1.





e) A variable declared in a for statement can be used again anywhere in the program code.





f) String variable are primitives data types.





g)The first charactr of the string has index position 1.





h) Strings are compared using relational operators such as %26gt;.





i) The string class includes a method for determining the location of a substring within a string.

JAVA! true/false questions?
a.) false


b.) false.


c.) false, but this might be semantics.


d.) ?


e.) false


f.) true


g.) false


h.) ? false ?


i.) true


Sharing an array between classes?

I have created a database class which creates a database object array with three objects in each index.





CODE


class Database


{





int answer = JOptionPane.YES_OPTION;


int count = 0;


final int ARRAY_SIZE = 12;





public Database(){








CD[] data = new CD[ARRAY_SIZE];


String[] search = new String[ARRAY_SIZE];





while (answer == JOptionPane.YES_OPTION)


{





String a;


String c;


int n;





a = JOptionPane.showInputDialog("Please, enter artist name");


c = JOptionPane.showInputDialog("Please, enter CD name");


n = Integer.parseInt(JOptionPane.showInputDi... enter total number of tracks"));





data[count] = new CD(a, c, n);


search[count]= new String(c);





answer = JOptionPane.showConfirmDialog(null, "Enter another record?",


"???", JOptionPane.YES_NO_OPTION);


count++;


}


}


}


I then created a new class called search that is supposed to search the array in my database class for whatever the user types in, which in this case is a cd name.





CODE


class Search


{


int result;


int ARRAY_SIZE=12;


String searchKey = JOptionPane.showInputDialog("Give me the name of a CD");





result = linearSearch(search, searchKey, ARRAY_SIZE);





if(result== -1)


{


JOptionPane.showMessageDialog(null,"KEY " + searchKey + " NOT FOUND");


}


else


{


JOptionPane.showMessageDialog(null,"KEY " + searchKey + " FOUND in position " + result);


}











public static int linearSearch(String[] search, String key, int sizeOfArray)


{


for (int counter = 0; counter %26lt; sizeOfArray; counter++)


{


if (search[counter].equalsIgnoreCase (key))


return counter;


}


return -1;


}


}


How do i get the array from the database class to the search class.





cheers

Sharing an array between classes?
1. create a main class. The main class creates a database object and a search object, and passes the database data structure to the search object.





2. move the search class inside the database class. The database datastructure could then be global to both classes.





3. use inheritance. keep the two classes seperate and have the search class extend the database class. You end up having two possible classes that can be declared: a base database, and a searchable database. In your search class you can access the database's data structure using super.search[]