Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   General IT Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=19)
-   -   Simple Java Program (https://www.cableforum.uk/board/showthread.php?t=33681256)

cnewton2k 20-09-2011 11:02

Simple Java Program
 
Hi,

I have just started at uni doing a BSc in Applied Computing and Multimedia.

We started on programming and i have been given a task to write a simple java program :

Write a program that converts 3.5 miles into inches using the following criteria.

3.5 * 1760 = 6160 yards 6160 * 3 = 18480 feet 18480 * 12 = 221760 inches

I have started in Netbeans and have done the following the following

package distance;

/**
*
* @author s0144037
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void Main(String[] args) {
double mile = 3.5;
double yard = mile * 1760;
double feet = yard * 3;
double inches = feet * 12;

System.out.println("3.5 Miles Converted into inches" = mile * yard * feet + inches);

}
}

Now when i try and run the it i get the error "No Main Classes Found".

I am not sure where i have gone wrong or even if i am on the right track!

If anyone could help explain that would be amazing :)

Thanks

downquark1 20-09-2011 11:07

Re: Simple Java Program
 
will try the main error in a moment:

for starters:

System.out.println("3.5 Miles Converted into inches" = mile * yard * feet + inches);

The = needs to be within the string and you need a string appending operator, in java I think its + but not sure so it should be

System.out.println("3.5 Miles Converted into inches = " + (mile * yard * feet + inches));

But I'm currently thinking in C++ so may get a bit wrong.

cnewton2k 20-09-2011 11:12

Re: Simple Java Program
 
I have changed that and as soon as i read it i realised what i had done wrong.

However it is still saying "no main classes found"

Thanks for your help with this :)

downquark1 20-09-2011 11:17

Re: Simple Java Program
 
ok found the problem.

public static void Main(String[] args) {

to


public static void main(String[] args) {

cnewton2k 20-09-2011 11:22

Re: Simple Java Program
 
doh!

we where told yesterday about capitals lol!

It finally works :) thank you ever so much i really do appreciate it :)

At least i was on the right track!


All times are GMT +1. The time now is 22:08.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum