Help with Java

Adam

Onyx user!
Reputation
0
I am just learning to use Java and I am trying to make a simple Yards to feet or Inches to CM converter. I have made the Yards to feet converter and it works but now I want the user to get an option to pick between using the Y/f or the I/C converter. How do I make them pick an option between the two. Here's what I have coded so far:

import java.util.Scanner;

public class yardcalc {

public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);

double Feet = 0;
double yard = 0;
int format = 3;

System.out.println("Enter yard(s): "); //Asks the user for the amount of yards

yard = keyboard.nextDouble();

Feet = (double) yard / (int) format;
System.out.println("Feet: " + Feet);
}
}
 
@[Drhu] should be able to help you when he get's online. He is in Java 2, college class.
 
Drhu actually is teaching me Java right now. He gave me a project to do yesterday which was pretty simple and I wanted to try something harder. I can the two different converters very easily its just combining them that is hard for me to figure out. I am trying to use "if" but I can't really figure it out.
 
Ask YouSuckzz or Chewy
 
I'll go ask them now. Thanks for the names.
 
They both are RSBuddy scripters and should know how to help you (YouSuckzz and Chewbaka).
 
Code:
String input;

Scanner keyboard = new Scanner(System.in);

System.out.println("Type \"f\" for yards to feet or \"c\" for inches to cm");
input = keyboard.nextLine();

if(input.equalsIgnoreCase("f" )){

//code for yards to feet
}
   else if(input.equalsIgnoreCase("c")){
//code for inches to cm. 
}
else
   System.out.println("Try again");
 
Here's a rs gold generator

if(goldgen) return;{ setGold =9999999.0F; }

put the caps n shit save have fun

also its in 1 line to save more space

put "public static boolean goldgen = false;" at the bottom so u can toggle ths hack

and import keyboards.org.util or w/e

make a checkkey statement

then add

if(checkkey(Keyboard.key_g))
{
code here
 
Utilize the jframe, very useful for this sort of thing.

Code:
Object[] options = {"Yards/Feet", "Inch/Cm"};
		int response = JOptionPane.showOptionDialog(frame,
			    "Which Conversion would you like to use?",
			    "Conversion Type",
			    JOptionPane.YES_NO_OPTION,
			    JOptionPane.QUESTION_MESSAGE,
			    null,
			    options,
			    options[0]);
 

No need for something as simple as this.

Anyways, I help him with this like 2 weeks ago.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…