Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-20-2004, 05:52 PM   #1
Member (9 bit)
 
colecifer's Avatar
 
Join Date: Jan 2004
Location: Kansas City(westwood), KS
Posts: 458
Help me please, can't make a custom class file work

I need to make a program where we make our own class and what it is suppoused to do is take two numbers and an operation sign, then compute. Here is my code and i get a couple errors i can't fix. Whats wrong with it?
Code:
public class Exercise
{
	
	
	public static void main(String args[])
	{
		System.out.println( Compute.computer(2.5, 0.5, + ));
		
	}




}
class Compute
{

	public static double computer(double double1, double double2, char char1)
	{
		double result;
		result = 0;
		
		switch (char1)
		{
		
		case '+': 
			result = double1 + double2;
			break;
		case '-':
			result = double1 - double2;
			break;
		case '*':
			result = double1 * double2;
			break;
		case '/':
			result = double1 / double2;
			break;
		}
		
		return result;			
	}
}
EDIT:
never mind i made it work, i just needed to put the operation in single quotes. Any mods that see this can go ahead and delete. No one replied so its sort of useless.

Last edited by colecifer; 10-20-2004 at 07:41 PM.
colecifer is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:10 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2