Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Distance2{
- static double miles =0; static double yards =1760;
- static void getDistance(){
- System.out.println("Enter in miles: ");
- miles = Console.readDouble();
- yards = miles * yards;
- System.out.println((int)miles + " miles or " + ((int)yards) + " yards");//the int bracket in front of mile and yards changes double to int! lololol
- }
- static void toStrings(){
- if(yards%1760!=0){
- System.out.println((int)miles + " miles " + ((int)yards%1760) + " yards " );
- }
- }
- public static void main(String [] args){
- getDistance();//
- toStrings();//these are static methods and the ones ^ Up there are too even miles and yards are (line 2) otherwise it wont work! theres no objects in this one and this is the main difference from when you're using static methods instead of objects! hope this helps you loads Did-Von Drogley haha :3
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment