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);


}