Post by clockwork on Dec 4, 2010 3:25:02 GMT
This is my longest lined code as of yet - 84 Lines
It is also one of my first attempts at a standalone code. Save a few others in my minor thread.
I felt as if this program deserved it's own thread.
It is also one of my first attempts at a standalone code. Save a few others in my minor thread.
I felt as if this program deserved it's own thread.
import java.util.Scanner;
class apples{
public static void main(String args[]){
Scanner op = new Scanner (System.in);
double operate, fnum, snum, answer;
System.out.print("What Operation do you wish to do? (Mult is 1, Div is 2, Add is 3, Sub is 4, Entering a number other than 1-4 will result in the program shutting down): ");
operate = op.nextDouble();
if (operate == 1){
System.out.println("Running Multiplication Program, please wait...");
System.out.println("Loaded!");
System.out.println("Enter the first digit you wish to Multiply by :");
fnum = op.nextDouble();
System.out.println("Enter the second digit you wish to Multiply by :");
snum = op.nextDouble();
answer = fnum * snum;
System.out.print("Your question was ");
System.out.print(fnum);
System.out.print(" multiplied by ");
System.out.print(snum);
System.out.print(" and your answer is ");
System.out.print(answer);
System.out.println("!");
}
if (operate == 2){
System.out.println("Running Division Program, please wait...");
System.out.println("Loaded!");
System.out.println("Enter the first digit you wish to Divide by :");
fnum = op.nextDouble();
System.out.println("Enter the second digit you wish to Divide by :");
snum = op.nextDouble();
answer = fnum / snum;
System.out.print("Your question was ");
System.out.print(fnum);
System.out.print(" divided by ");
System.out.print(snum);
System.out.print(" and your answer is ");
System.out.print(answer);
System.out.println("!");
}
if (operate == 3){
System.out.println("Running Addition Program, please wait...");
System.out.println("Loaded!");
System.out.println("Enter the first digit you wish to Add by :");
fnum = op.nextDouble();
System.out.println("Enter the second digit you wish to Add by :");
snum = op.nextDouble();
answer = fnum + snum;
System.out.print("Your question was ");
System.out.print(fnum);
System.out.print(" added by ");
System.out.print(snum);
System.out.print(" and your answer is ");
System.out.print(answer);
System.out.println("!");
}
if (operate == 4){
System.out.println("Running Subtraction Program, please wait...");
System.out.println("Loaded!");
System.out.println("Enter the first digit you wish to Subtract by :");
fnum = op.nextDouble();
System.out.println("Enter the second digit you wish to Subtract by :");
snum = op.nextDouble();
answer = fnum - snum;
System.out.print("Your question was ");
System.out.print(fnum);
System.out.print(" subtracted by ");
System.out.print(snum);
System.out.print(" and your answer is ");
System.out.print(answer);
System.out.println("!");
}
else{
System.out.println("Program Over");
}
}}