What line is that on?
When I compile this program it says "cannot find symbol class Method Master", but when I run it, everything is fine.
/*
*Andrew Davis
*Nov. 19, 2010
*/
import java.util.Scanner;
public class Calculator
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
MethodMaster method = new MethodMaster();
int question1;
double num1;
double num2;
double length;
double width;
double side1;
double side2;
double side3;
double base;
double height;
double radius;
double fahrenheit;
double centigrade;
double value = 0;
method.printMenu();
question1 = keyboard.nextInt();
System.out.println();
switch(question1)
{
case 1: //Add two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " + " + num2 + " = " + method.addNumbers(num1, num2, value));
break;
}
case 2: //Subtract two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " - " + num2 + " = " + method.subtractNumbers(num1, num2, value));
break;
}
case 3: //Multiply two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " * " + num2 + " = " + method.multiplyNumbers(num1, num2, value));
break;
}
case 4: //Divide two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " / " + num2 + " = " + method.divideNumbers(num1, num2, value));
break;
}
case 5: //Find the …
That was cool!
The specific question was, can you create java programs in C++
I have no idea how C++ works, but I'd like to learn...
Is it possible to create java files/programs using C++?
hi frnds i want some small basic java projcts samples and some tips to develop a projct plzz help me..
What do you mean? What kind of project?
This program asks for your name, you type in your name or whatever you want and press enter, then it will tell you how many characters (including spaces) are in the string.
import java.util.Scanner;
public class YourProgramName
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner (System.in);
String name;
System.out.println ("Enter Your Name");
name = keyboard.nextLine();
int stringLength = name.length();
System.out.println(stringLength);
}
}
everything is fine when i click it so it should be fine
How do I create an Instant Messenger Program using Java?
I want to create an Instant Messenger Program using Java, and I dont have a clue where to start, so if someone can please help me, that would be great.
Thank You,
Andrew Davis
So how would I do that? I dont know the values because the values are gonna be whatever someone puts in the box, right?
that statement is supposed to add g1 and g2, and i want the values of g1 and g2 to be whatever someone puts into a text box thing
THIS IS A PROGRAM THAT WILL OPEN A WINDOW, THEN WHEN YOU CLICK CALCULATE GPA, A JOPTIONPANE THING WILL OPEN AND YOU WILL PUT YOUR GRADE IN, THAT WILL HAPPEN 2 MORE TIMES THEN THE LAST ONE WILL SHOW YOU YOUR GRADE AVERAGE.
WHEN I COMPILE THIS PROGRAM, EVERYTHING IS FINE, BUT WHEN I PRESS EXECUTE, IT DOES NOT RUN MY PROGRAM IT JUST SAYS:
Exception in thread "main" java.lang.NullPointerException
at Menus2.<init>(Menus2.java:12)
at Menus2.main(Menus2.java:67)
Process completed.
PLEASE HELP ME, THIS PROBLEM IS PROBABLY SOMETHING STUPID, BUT I CANT SEEM TO FIGURE IT OUT
THANK YOU,
A. DAVIS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Menus2 extends JFrame implements ActionListener{
JButton k1, k2;
Integer g1 =(null);
Integer g2 =(null);
int g3 = g1 + g2;
public Menus2(){
this.setSize(400,300);
this.setTitle("GPA Calculator");
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setLayout(new FlowLayout());
Container content = getContentPane();
k1 = new JButton("Close Program");
k1.setActionCommand("Exit");
k2 = new JButton("Calculate GPA");
k2.setActionCommand("Name");
k1.addActionListener(this);
k2.addActionListener(this);
content.add(k1, BorderLayout.NORTH);
content.add(k2, BorderLayout.WEST);
}
public void actionPerformed(ActionEvent e){
if((e.getActionCommand()).equals("Exit")) {
System.exit(0);
}
if((e.getActionCommand()).equals("Name")) {
g1 = Integer.parseInt("Enter 1st Grade: ");
g2 = Integer.parseInt("Enter 2st Grade: ");
g3 = Integer.parseInt("Enter 3st Grade: ");
JOptionPane.showMessageDialog(null, "Your GPA is " + g3);
}
}
public static void main(String[] args) {
Menus2 project = new Menus2();
project.setVisible(true);
}
}