This was originally just a calculator without a decimal point. After I added the decimal, it now tells me invalid second number. - //GUI Calculator Program
-
-
import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import java.io.*;
-
-
public class Calculator extends JFrame implements ActionListener
-
{
-
private JTextField displayText = new JTextField(30);
-
private JButton[] button = new JButton[20];
-
-
private String[] keys = {"7", "8", "9", "/",
-
"4", "5", "6", "*",
-
"1", "2", "3", "-",
-
"0", "C", "=", "+",
-
".", " ", " ", " "};
-
-
private String numStr1 = "";
-
private String numStr2 = "";
-
-
private char op;
-
private boolean firstInput = true;
-
-
public Calculator()
-
{
-
setTitle("My Calculator");
-
setSize(230, 250);
-
Container pane = getContentPane();
-
-
pane.setLayout(null);
-
-
displayText.setSize(200, 30);
-
displayText.setLocation(10, 10);
-
pane.add(displayText);
-
-
int x, y;
-
-
x = 10;
-
y = 40;
-
for (int ind = 0; ind < 20; ind++)
-
{
-
button[ind] = new JButton(keys[ind]);
-
button[ind].addActionListener(this);
-
button[ind].setSize(50, 30);
-
button[ind].setLocation(x, y);
-
pane.add(button[ind]);
-
x = x + 50;
-
if((ind + 1) % 4 == 0)
-
{
-
x = 10;
-
y = y + 30;
-
}
-
}
-
-
this.addWindowListener(new WindowAdapter()
-
{
-
public void windowClosing(WindowEvent e)
-
{
-
System.exit(0);
-
}
-
}
-
);
-
-
setVisible(true);
-
setDefaultCloseOperation(EXIT_ON_CLOSE);
-
}
-
-
public void actionPerformed(ActionEvent e)
-
{
-
String resultStr; //Step 1
-
String str = String.valueOf(e.getActionCommand()); //Steps 1 and 2
-
-
char ch = str.charAt(0); //Steps 1 and 3
-
-
switch (ch) //Step 4
-
{
-
case '0': case '1': case '2': //Step 4a
-
case '3': case '4': case '5':
-
case '6': case '7': case '8':
-
case '9': case '.':if (firstInput)
-
{
-
numStr1 = numStr1 + ch;
-
displayText.setText(numStr1);
-
}
-
else
-
{
-
numStr2 = numStr2 + ch;
-
displayText.setText(numStr2);
-
}
-
break;
-
case '+': case '-': case '*': //Step 4b
-
case '/': op = ch;
-
firstInput = false;
-
break;
-
case '=': resultStr = evaluate(); //Step 4c
-
displayText.setText(resultStr);
-
numStr1 = resultStr;
-
numStr2 = "";
-
firstInput = false;
-
break;
-
case 'C': displayText.setText(""); //Step 4c
-
numStr1 = "";
-
numStr2 = "";
-
firstInput = true;
-
}
-
}
-
-
private String evaluate()
-
{
-
final char beep = '\u0007';
-
-
try
-
{
-
int num1 = Integer.parseInt(numStr1);
-
int num2 = Integer.parseInt(numStr2);
-
int result = 0;
-
-
switch (op)
-
{
-
case '+': result = num1 + num2;
-
break;
-
case '-': result = num1 - num2;
-
break;
-
case '*': result = num1 * num2;
-
break;
-
case '/': result = num1 / num2;
-
}
-
-
return String.valueOf(result);
-
}
-
catch(ArithmeticException e)
-
{
-
System.out.print(beep);
-
return "E R R O R: " + e.getMessage();
-
}
-
catch(NumberFormatException e)
-
{
-
System.out.print(beep);
-
if (numStr1.equals(""))
-
return "E R R O R: Invalid First Number" ;
-
else
-
return "E R R O R: Invalid Second Number" ;
-
}
-
catch(Exception e)
-
{
-
System.out.print(beep);
-
return "E R R O R";
-
}
-
}
-
-
public static void main(String[] args)
-
{
-
Calculator C = new Calculator();
-
}
-
}
Please Help
19 3977
Sorry Texas for the late reply. You were previously dealing with integers(without the decimal point).
To capture integers Integer.parseInt was used which was adequate. When you added the decimal point, Integer.parseInt was no longer sufficient. You now need Double.parseDouble and change your variables from int type to double type. I have made these changes below. - import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import java.io.*;
-
-
public class Calculator extends JFrame implements ActionListener {
-
private JTextField displayText = new JTextField(30);
-
private JButton[] button = new JButton[20];
-
private String[] keys = {"7", "8", "9", "/",
-
"4", "5", "6", "*",
-
"1", "2", "3", "-",
-
"0", "C", "=", "+",
-
".", " ", " ", " "};
-
private String numStr1 = "";
-
private String numStr2 = "";
-
private char op;
-
private boolean firstInput = true;
-
public Calculator() {
-
setTitle("My Calculator");
-
setSize(230, 250);
-
Container pane = getContentPane();
-
pane.setLayout(null);
-
displayText.setSize(200, 30);
-
displayText.setLocation(10, 10);
-
pane.add(displayText);
-
int x, y;
-
x = 10;
-
y = 40;
-
for (int ind = 0; ind < 20; ind++) {
-
button[ind] = new JButton(keys[ind]);
-
button[ind].addActionListener(this);
-
button[ind].setSize(50, 30);
-
button[ind].setLocation(x, y);
-
pane.add(button[ind]);
-
x = x + 50;
-
if((ind + 1) % 4 == 0) {
-
x = 10;
-
y = y + 30;
-
}
-
}
-
-
this.addWindowListener(new WindowAdapter() {
-
public void windowClosing(WindowEvent e) {
-
System.exit(0);
-
}
-
});
-
-
setVisible(true);
-
setDefaultCloseOperation(EXIT_ON_CLOSE);
-
}
-
-
public void actionPerformed(ActionEvent e) {
-
String resultStr; //Step 1
-
String str = String.valueOf(e.getActionCommand()); //Steps 1 and 2
-
char ch = str.charAt(0); //Steps 1 and 3
-
switch (ch) //Step 4
-
{
-
case '0': case '1': case '2': //Step 4a
-
case '3': case '4': case '5':
-
case '6': case '7': case '8':
-
case '9': case '.':if (firstInput)
-
{
-
numStr1 = numStr1 + ch;
-
displayText.setText(numStr1);
-
}
-
else
-
{
-
numStr2 = numStr2 + ch;
-
displayText.setText(numStr2);
-
}
-
break;
-
case '+': case '-': case '*': //Step 4b
-
case '/': op = ch;
-
firstInput = false;
-
break;
-
case '=': resultStr = evaluate(); //Step 4c
-
displayText.setText(resultStr);
-
numStr1 = resultStr;
-
numStr2 = "";
-
firstInput = false;
-
break;
-
case 'C': displayText.setText(""); //Step 4c
-
numStr1 = "";
-
numStr2 = "";
-
firstInput = true;
-
}
-
}
-
-
private String evaluate()
-
{
-
final char beep = '\u0007';
-
-
try
-
{
-
double num1 = Double.parseDouble(numStr1);// Changed here
-
double num2 = Double.parseDouble(numStr2);//
-
double result = 0;
-
-
switch (op)
-
{
-
case '+': result = num1 + num2;
-
break;
-
case '-': result = num1 - num2;
-
break;
-
case '*': result = num1 * num2;
-
break;
-
case '/': result = num1 / num2;
-
}
-
-
return String.valueOf(result);
-
}
-
catch(ArithmeticException e)
-
{
-
System.out.print(beep);
-
return "E R R O R: " + e.getMessage();
-
}
-
catch(NumberFormatException e)
-
{
-
System.out.print(beep);
-
if (numStr1.equals(""))
-
return "E R R O R: Invalid First Number" ;
-
else
-
return "E R R O R: Invalid Second Number" ;
-
}
-
catch(Exception e)
-
{
-
System.out.print(beep);
-
return "E R R O R";
-
}
-
}
-
-
public static void main(String[] args)
-
{
-
Calculator C = new Calculator();
-
}
-
}
I cant believe that it was something that I overlooked. A special thanks to r035198x, for not only looking over the code, but for helping me out.
I cant believe that it was something that I overlooked. A special thanks to r035198x, for not only looking over the code, but for helping me out.
Just post any Java problems you get anytime. The guys here are always willing to help.
further problem now I am getting infinity if I divide by zero. The exception should have caught it and given it an error : / by zero. Now, what have I forgotten?
In your evaluate() method, if the op is division, you should check that num2 != 0.0 (the program does not do this check for you because it is not an invalid number on parsing). you can do something like: -
if(num2 == 0.0)
-
{
-
throw new ArithmeticException("Can't Divide by 0");
-
}
-
further problem now I am getting infinity if I divide by zero. The exception should have caught it and given it an error : / by zero. Now, what have I forgotten?
Tricky one for you this.
Now dividing by (double) 0.0 does not cause an exception. The result is simply Infinity. This is because double are approximations and not exact values so 0.0 is a number as close to zero as possible....
Dividing by (int) 0 is the one that throws the / by zero exception.
Tricky one for you this.
Now dividing by (double) 0.0 does not cause an exception. The result is simply Infinity. This is because double are approximations and not exact values so 0.0 is a number as close to zero as possible....
Dividing by (int) 0 is the one that throws the / by zero exception.
Now I'm really confused as to were I would insert the Dividing by (int) 0 or were I would put the throw exception to make this happen? I have tried install it in several places in the code and all I get is error after error. I'm really lost here!
Now I'm really confused as to were I would insert the Dividing by (int) 0 or were I would put the throw exception to make this happen? I have tried install it in several places in the code and all I get is error after error. I'm really lost here!
- double num1 = Double.parseDouble(numStr1);// Changed here
-
double num2 = Double.parseDouble(numStr2);//
-
double result = 0;
These lines of code guarantee that you are never going to get a / by zero exception because you are now operating on doubles which give Infinity on / by zero rather than on ints which give that exception.
If you want to stop the program from getting infinity as a result then test the result with - if((result == Double.POSITIVE_INFINITY) || (result == Double.NEGATIVE_INFINITY)) {
-
System.out.println("error");
-
e.t.c
-
}
Okay, I put the statement were thought it should go but it still comes up infinity, any other hints clues suggestions? Or am I just an idiot? See below
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Calculator extends JFrame implements ActionListener {
private JTextField displayText = new JTextField(30);
private JButton[] button = new JButton[20];
private String[] keys = {"7", "8", "9", "/",
"4", "5", "6", "*",
"1", "2", "3", "-",
"0", "C", "=", "+",
".", " ", " ", " "};
private String numStr1 = "";
private String numStr2 = "";
private char op;
private boolean firstInput = true;
public Calculator() {
setTitle("My Calculator");
setSize(230, 250);
Container pane = getContentPane();
pane.setLayout(null);
displayText.setSize(200, 30);
displayText.setLocation(10, 10);
pane.add(displayText);
int x, y;
x = 10;
y = 40;
for (int ind = 0; ind < 20; ind++) {
button[ind] = new JButton(keys[ind]);
button[ind].addActionListener(this);
button[ind].setSize(50, 30);
button[ind].setLocation(x, y);
pane.add(button[ind]);
x = x + 50;
if((ind + 1) % 4 == 0) {
x = 10;
y = y + 30;
}
}
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
String resultStr; //Step 1
String str = String.valueOf(e.getActionCommand()); //Steps 1 and 2
char ch = str.charAt(0); //Steps 1 and 3
switch (ch) //Step 4
{
case '0': case '1': case '2': //Step 4a
case '3': case '4': case '5':
case '6': case '7': case '8':
case '9': case '.':if (firstInput)
{
numStr1 = numStr1 + ch;
displayText.setText(numStr1);
}
else
{
numStr2 = numStr2 + ch;
displayText.setText(numStr2);
}
break;
case '+': case '-': case '*': //Step 4b
case '/': op = ch;
firstInput = false;
break;
case '=': resultStr = evaluate(); //Step 4c
displayText.setText(resultStr);
numStr1 = resultStr;
numStr2 = "";
firstInput = false;
break;
case 'C': displayText.setText(""); //Step 4c
numStr1 = "";
numStr2 = "";
firstInput = true;
}
}
private String evaluate()
{
final char beep = '\u0007';
try
{
double num1 = Double.parseDouble(numStr1);
double num2 = Double.parseDouble(numStr2);
double result = 0;
if((result == Double.POSITIVE_INFINITY) || (result == Double.NEGATIVE_INFINITY))
{
System.out.println("error");
}
switch (op)
{
case '+': result = num1 + num2;
break;
case '-': result = num1 - num2;
break;
case '*': result = num1 * num2;
break;
case '/': result = num1 / num2;
}
return String.valueOf(result);
}
catch(ArithmeticException e)
{
System.out.print(beep);
return "E R R O R:" + e.getMessage();
}
catch(NumberFormatException e)
{
System.out.print(beep);
if (numStr1.equals(""))
return "E R R O R: Invalid First Number" ;
else
return "E R R O R: Invalid Second Number" ;
}
catch(Exception e)
{
System.out.print(beep);
return "E R R O R";
}
}
public static void main(String[] args)
{
Calculator C = new Calculator();
}
}
Makes sense to put it after the result is calculated - switch (op)
-
{
-
case '+': result = num1 + num2;
-
break;
-
case '-': result = num1 - num2;
-
break;
-
case '*': result = num1 * num2;
-
break;
-
case '/': result = num1 / num2;
-
}
-
}
-
if((result == Double.POSITIVE_INFINITY) || (result == Double.NEGATIVE_INFINITY))
-
{
-
System.out.println("error");
-
return "E R R O R:"
-
}
-
else {
-
return String.valueOf(result);
-
}
-
}
-
catch(ArithmeticException e)
-
{
-
System.out.print(beep);
-
+ e.getMessage();
-
}
P.S Use code tags for posting code
private String evaluate()
{
final char beep = '\u0007';
try
{
double num1 = Double.parseDouble(numStr1);
double num2 = Double.parseDouble(numStr2);
double result = 0;
switch (op)
{
case '+': result = num1 + num2;
break;
case '-': result = num1 - num2;
break;
case '*': result = num1 * num2;
break;
case '/': result = num1 / num2;
}
if ((result == Double.POSITIVE_INFINITY) || (result == Double.NEGATIVE_INFINITY))
{
System.out.print(beep);
return "E R R O R:";
}
else
return String.valueOf(result);
}
catch(ArithmeticException e)
{
System.out.print(beep);
}
catch(NumberFormatException e)
{
System.out.print(beep);
if (numStr1.equals(""))
return "E R R O R: Invalid First Number" ;
else
return "E R R O R: Invalid Second Number" ;
}
catch(Exception e)
{
System.out.print(beep);
return "E R R O R";
}
finally
{
Calculator C = new Calculator();
}
} //line 153 this is the close for try
//line 154
} //line 155 this is te close for privat string
Okay, I am about as frustrated with this thing as I can be. I went back to the book thinking that there had to be a finally statement, but that didn't work I keep getting a missing return statement on line 153
I Don't remember exactly how exceptions work, but I think your "finally" block is incorrect - can the code ever get here? (I think the compiler expects you to return a value here, which would be a fix, but I think the code will never reach this point so you should delete it).
Basically the "finally" is executed irrespective of which exception is thrown, but all of your exceptions have a return line which will stop execution of that method before it gets to finally.....
- catch(ArithmeticException e)
-
{
-
System.out.print(beep);
-
}
This catch() block has no return statement, so it is possible that there will not be a return - this is why you get an error. Perhaps you should add the line
as you have in other blocks.
I would like to thank everyone for thier input and let you know that I have resolved all issues with this project. New one to come soon. Expect to hear more from me. Thanks again.
I would like to thank everyone for thier input and let you know that I have resolved all issues with this project. New one to come soon. Expect to hear more from me. Thanks again.
Mind postin the final version you ended up with?
Final code: - /**
-
* Description: This takes the original calculator program that could be used
-
* on integers and converts it to be able to use decimal numbers. Division by
-
* zero creates error resulting in ERROR: / by zero.
-
*/
-
import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import java.io.*;
-
-
public class Calculator extends JFrame implements ActionListener
-
{
-
private JTextField displayText = new JTextField(30);
-
private JButton[] button = new JButton[20];
-
private String[] keys =
-
{"7", "8", "9", "/",
-
"4", "5", "6", "*",
-
"1", "2", "3", "-",
-
"0", "C", "=", "+",
-
".", " ", " ", " "};
-
private String numStr1 = "";
-
private String numStr2 = "";
-
private char op;
-
private boolean firstInput = true;
-
public Calculator()
-
{
-
setTitle("My Calculator");
-
setSize(230, 250);
-
Container pane = getContentPane();
-
pane.setLayout(null);
-
displayText.setSize(200, 30);
-
displayText.setLocation(10, 10);
-
pane.add(displayText);
-
int x, y;
-
x = 10;
-
y = 40;
-
for (int ind = 0; ind < 20; ind++)
-
{
-
button[ind] = new JButton(keys[ind]);
-
button[ind].addActionListener(this);
-
button[ind].setSize(50, 30);
-
button[ind].setLocation(x, y);
-
pane.add(button[ind]);
-
x = x + 50;
-
if((ind + 1) % 4 == 0) {
-
x = 10;
-
y = y + 30;
-
}
-
}
-
-
this.addWindowListener(new WindowAdapter()
-
{
-
public void windowClosing(WindowEvent e)
-
{
-
System.exit(0);
-
}
-
});
-
-
setVisible(true);
-
setDefaultCloseOperation(EXIT_ON_CLOSE);
-
}
-
-
public void actionPerformed(ActionEvent e)
-
{
-
String resultStr; //Step 1
-
String str = String.valueOf(e.getActionCommand()); //Steps 1 and 2
-
char ch = str.charAt(0); //Steps 1 and 3
-
switch (ch) //Step 4
-
{
-
case '0': case '1': case '2': //Step 4a
-
case '3': case '4': case '5':
-
case '6': case '7': case '8':
-
case '9': case '.':if (firstInput)
-
{
-
numStr1 = numStr1 + ch;
-
displayText.setText(numStr1);
-
}
-
else
-
{
-
numStr2 = numStr2 + ch;
-
displayText.setText(numStr2);
-
}
-
break;
-
case '+': case '-': case '*': //Step 4b
-
case '/': op = ch;
-
firstInput = false;
-
break;
-
case '=': resultStr = evaluate(); //Step 4c
-
displayText.setText(resultStr);
-
numStr1 = resultStr;
-
numStr2 = "";
-
firstInput = false;
-
break;
-
case 'C': displayText.setText(""); //Step 4c
-
numStr1 = "";
-
numStr2 = "";
-
firstInput = true;
-
}
-
}
-
-
private String evaluate()
-
{
-
final char beep = '\u0007';
-
-
try
-
{
-
double num1 = Double.parseDouble(numStr1);
-
double num2 = Double.parseDouble(numStr2);
-
double result = 0;
-
-
switch (op)
-
{
-
case '+': result = num1 + num2;
-
break;
-
case '-': result = num1 - num2;
-
break;
-
case '*': result = num1 * num2;
-
break;
-
case '/': result = num1 / num2;
-
}
-
if ((result == Double.POSITIVE_INFINITY) || (result == Double.NEGATIVE_INFINITY))
-
{
-
System.out.print(beep);
-
return "E R R O R: / by zero";
-
}
-
else
-
return String.valueOf(result);
-
}
-
catch(ArithmeticException e)
-
{
-
System.out.print(beep);
-
return "E R R O R:";
-
}
-
catch(NumberFormatException e)
-
{
-
System.out.print(beep);
-
if (numStr1.equals(""))
-
return "E R R O R: Invalid First Number" ;
-
else
-
return "E R R O R: Invalid Second Number" ;
-
}
-
catch(Exception e)
-
{
-
System.out.print(beep);
-
return "E R R O R";
-
}
-
}
-
public static void main(String[] args)
-
{
-
Calculator C = new Calculator();
-
}
-
-
}
Final code:
/**
* Description: This takes the original calculator program that could be used
* on integers and converts it to be able to use decimal numbers. Division by
* zero creates error resulting in ERROR: / by zero.
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Calculator extends JFrame implements ActionListener
{
private JTextField displayText = new JTextField(30);
private JButton[] button = new JButton[20];
private String[] keys =
{"7", "8", "9", "/",
"4", "5", "6", "*",
"1", "2", "3", "-",
"0", "C", "=", "+",
".", " ", " ", " "};
private String numStr1 = "";
private String numStr2 = "";
private char op;
private boolean firstInput = true;
public Calculator()
{
setTitle("My Calculator");
setSize(230, 250);
Container pane = getContentPane();
pane.setLayout(null);
displayText.setSize(200, 30);
displayText.setLocation(10, 10);
pane.add(displayText);
int x, y;
x = 10;
y = 40;
for (int ind = 0; ind < 20; ind++)
{
button[ind] = new JButton(keys[ind]);
button[ind].addActionListener(this);
button[ind].setSize(50, 30);
button[ind].setLocation(x, y);
pane.add(button[ind]);
x = x + 50;
if((ind + 1) % 4 == 0) {
x = 10;
y = y + 30;
}
}
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
String resultStr; //Step 1
String str = String.valueOf(e.getActionCommand()); //Steps 1 and 2
char ch = str.charAt(0); //Steps 1 and 3
switch (ch) //Step 4
{
case '0': case '1': case '2': //Step 4a
case '3': case '4': case '5':
case '6': case '7': case '8':
case '9': case '.':if (firstInput)
{
numStr1 = numStr1 + ch;
displayText.setText(numStr1);
}
else
{
numStr2 = numStr2 + ch;
displayText.setText(numStr2);
}
break;
case '+': case '-': case '*': //Step 4b
case '/': op = ch;
firstInput = false;
break;
case '=': resultStr = evaluate(); //Step 4c
displayText.setText(resultStr);
numStr1 = resultStr;
numStr2 = "";
firstInput = false;
break;
case 'C': displayText.setText(""); //Step 4c
numStr1 = "";
numStr2 = "";
firstInput = true;
}
}
private String evaluate()
{
final char beep = '\u0007';
try
{
double num1 = Double.parseDouble(numStr1);
double num2 = Double.parseDouble(numStr2);
double result = 0;
switch (op)
{
case '+': result = num1 + num2;
break;
case '-': result = num1 - num2;
break;
case '*': result = num1 * num2;
break;
case '/': result = num1 / num2;
}
if ((result == Double.POSITIVE_INFINITY) || (result == Double.NEGATIVE_INFINITY))
{
System.out.print(beep);
return "E R R O R: / by zero";
}
else
return String.valueOf(result);
}
catch(ArithmeticException e)
{
System.out.print(beep);
return "E R R O R:";
}
catch(NumberFormatException e)
{
System.out.print(beep);
if (numStr1.equals(""))
return "E R R O R: Invalid First Number" ;
else
return "E R R O R: Invalid Second Number" ;
}
catch(Exception e)
{
System.out.print(beep);
return "E R R O R";
}
}
public static void main(String[] args)
{
Calculator C = new Calculator();
}
}
Might want to work on indenting your code and making use of {} to make your code readable.
On the actual code that I have on my system it is all indented, but when I copied it over this is what happened. Again thanks for your help.
On the actual code that I have on my system it is all indented, but when I copied it over this is what happened. Again thanks for your help.
Try editing the display options on your control panel some where at the bottom of the control panel page.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mwh |
last post by:
Hi. If you remember, I posted Expressons Help. Now I am making a
calculator with javascript. I can't get this to work:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
|
by: James |
last post by:
Hi all, I'm making a mini calculator for fun. My only problem is home
to convert the string in the text box to a double so it can be added,
subtracted, etc. I'm sure most people know how, but I'm a...
|
by: PieMan2004 |
last post by:
Hi, ive been looking for a solid java community to help me when im tearing out my hair :)
Basically ive constructed a GUI that has to represent the same look and functions of the typical windows...
|
by: firstcustomer |
last post by:
Hi,
Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that
someone will be able to point me to a ready-made solution to my
problem!
A friend of mine (honest!) is wanting to...
|
by: arnuld |
last post by:
Stroustrup starts chapter 6 with a programme for desk-calculator:
here is a grammer for the langugae accepted by the calcualtor:
program:
END // END is end-of-input...
|
by: itsmichelle |
last post by:
This is a very primative code of a java swing calculator. I have assigned all the number buttons and the operator buttons and I can add, subtract, multiply, and divide two numbers together. However,...
|
by: deezle |
last post by:
Hello,
I am trying to get my calculator GUI to +,-,* and /. I have got all of them to work except my division. I was wondering if someone could helpme figure out the problem. Any input would help...
|
by: clairelee0322 |
last post by:
This program doesn't run because some problem with the reduce fraction.
My reduce fraction is all right but when I tried to put that in this program, It has some errors.
Or maybe the switch menu is...
|
by: aprillynn82 |
last post by:
I can not seem to get the code correct to calculate shipping charges based on weight and distance. The info is:
Weight of the Package (in kilograms) / Shipping rate per Mile
2kg or less / $0.01...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |