How can I make the numbers to stay at the textfield of my calculator instead of disappear like when I type 1 then hit the + sign the number 1 disappears from the textfield I would like to have this (1+1) showing in the text field and also if try to press only + , * , - , / to show error.
so for my computer science class, we have the following problem:
In your documentation be sure to say which loop you thought was easier to implement for this program and why Write a program that produces the following outputs. The first line of output must be written using a For-Loop. The second, using a While-Loop and the third using a Do-Loop.
You look at the program and smile because you see that the series is just the numbers 1-10 squared...just one line is in reverse order. No problem! As you start typing you discover that the number 8 key on your keyboard is not working. For this program you are unable to use the multiplication key
So, back to the drawing board. By staring at the sequence a light comes on and you are able to quickly finish this program WITHOUT using mulitiplication (or the Math class/ solve with arithmetic operators +, - or / ) .
Sample output:
For Loop 1 4 9 16 25 36 49 64 81 100
While Loop 100 81 64 49 36 25 16 9 4 1
Do While Loop 1 4 9 16 25 36 49 64 81 100
I have the "for" done, but I did it with a "for" in the beginning but then had a multitude of nested "if" loops so that I could do 7*7=7+7+7+7+7+7+7
I want users to input their phone Number But I want to make sure it is a phone number so they don't just do 1 and then leave it.
public static void main(String[] args) { // Create the Scanner Scanner in = new Scanner(System.in); // Create the Variables int phone; if(phone > 100000000000 || phone < 100000000000) { System.err.println("Error"); }
By the Way there are 12 digits in the if statement so that is 11 0's. Because all phone numbers are 12 digits.But when I run it, it comes up with an error saying The literal 100000000000000000000 of type int is out of range.I don't know how to make it so that the int has a limited number.
I want users to input their phone Number But I want to make sure it is a phone number so they don't just do 1 and then leave it.
public static void main(String[] args) { // Create the Scanner Scanner in = new Scanner(System.in); // Create the Variables int phone; if(phone > 100000000000 || phone < 100000000000) { System.err.println("Error"); }
By the Way there are 12 digits in the if statement so that is 11 0's. Because all phone numbers are 12 digits.But when I run it, it comes up with an error saying The literal 100000000000000000000 of type int is out of range.I don't know how to make it so that the int has a limited number.
There's a site that uses DBsign UWS to validate personal certificates on a smart card. I wound up breaking that functionality by moving the default Java truststore so I could create a new one with just root/intermediate CAs that I trust (I have no desire to allow apps signed in China, Russia, Turkey, and countries spelled with heiroglyphs). Now, my browser believes the UWS is self-signed and rfuses to run it. I need to find the certificate used to sign that app to see which cert(s) signed it, so I can add them back to the truststore. How can I find that?
import javax.swing.*; import java.awt.MenuBar; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class NewCalculator implements ActionListener { //assign button clicked number and answer onto variables.
[Code] .....
Also what is the code I need to use to do the percentage and square root calculation in the calculation. Cos I am not sure about the sign I am required to use to do the calculation.
The if statement is where the code to make the clear button (C and CE) work.
I have a checksum function that is suppose to read IPV4 packet and return a short integer value. The IPV4 packets are stored in a byte array. I am having trouble storing the first 8 bits and second 8 bits of the short integer into the byte arrays especially when they have leading 1s. For example, if my checksum returns 5571 (binary = 0001 0101 1100 0011) The first 8 bits is suppose to represent 195 but when I try to assign a larger integer type to a btye the information gets sign extended. The 195 turns into -61. I tried using bit addition like array[10] = array[10] & 0xff, but the result remains the same.
public static short checksum(byte [] a, int length) { short sum = 0; long data; int i = 0; while(length > 1) { data = (((a[i] << 8) & 0xff00) | ((a[i + 1]) & 0xff)); sum += data;
i know that int [][] x = new int[2][2] will generate a 2x2 array but I'm looking at a certification mock question and I see double [][] da = new double [3][]. What is the empty [] on the right hand side of the equal sign trying to tell me? Is there some default value?
This might make me look pretty silly but I was curious if there was a way to make a dynamic web page in java. Basically only using pure Java, with only HTML5, CSS and mySQL.
I need the username produced by this program to be in all lower case. The code is below.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
package dcollinshw03; import java.util.Scanner; import java.util.Random; public class DcollinsHW03 { public DcollinsHW03() {
So, Iv'e been trying to make a simple Text Based RPG with Java, and it is going quite well, and my friends want to play it too but they aren't very tech savvy, so it's hard to tell them to get an IDE or use the CMD, so I wanted to know if there was a way to make my text-based game into a window, like using JFrame or something. All i need is a window that displays the text, and a bar on the bottom that lets the user input what they want (Kind of like a CMD).
import java.util.Scanner; public class Exercise1{ public static void main(String[] args) { String employeeName, employeeNumber, position, department ; double otpay, salary, deduction, hrs, rate ; Scanner input = new Scanner (System.in);
[Code] ....
That's my codes but its wrong according to our prof. it should be in frame form. i don't know how to do it since i did not encountered framing since i was started in java.
How to calculate the minimum and the maximum in the same program.
public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int integers; int[] numbers; numbers = new int[10]; int max; int min;
[Code] ....
My result when I input numbers are always the following:
"Numbers in reverse order are: 9, Numbers in reverse order are: 8, Numbers in reverse order are: 7, Numbers in reverse order are: 6 Numbers in reverse order are: 5, Numbers in reverse order are: 4, Numbers in reverse order are: 3, Numbers in reverse order are: 2, Numbers in reverse order are: 1, Numbers in reverse order are: 0."
package com.arraydemo; import java.util.TimeZone; import java.util.concurrent.TimeUnit; public class ArrayStructures { public long[] theArray; public int arraySize; public ArrayStructures(int size)
So I was making a Java Calculator that only adds. The problem is that the numbers are not adding. I think it is because whatever has been clicked is not being saved to be added.
I am trying to do this assignment but I can't get the needed output. Create a program that asks the user how many floating point numbers he wants to give. After this the program asks the numbers, stores them in an array and prints the contents of the array in reverse order.
Program is written to a class called ReverseNumbers.
Example output
How many floating point numbers do you want to type: 5 Type in 1. number: 5,4 Type in 2. number: 6 Type in 3. number: 7,2 Type in 4. number: -5 Type in 5. number: 2
Given numbers in reverse order: 2.0 -5.0 7.2 6.0 5.4
My code:
import java.util.Scanner; public class apples { public static void main(String[] args) { Scanner reader = new Scanner(System.in); double[] numbers; System.out.print("How many floating point numbers do you want to type: ");
I need a regular expression in java for phone number which that does not allow any character special character only numbers should be allowed.. My sample program is
import java.util.regex.Matcher; import java.util.regex.Pattern; public class c { public String removeOrReplacePhoneNumber(String input) { if (null == input) return input;
in Operator/Literals, it says "There is no literal representation for binary numbers in C, C++, or Java." seems "0b11001" could reprensent binary numbers?
I am working on an assignment but I am not getting any out put and I couldn't fix it?The class HighLow below asks for three integers and prints the highest and lowest of them on screen. Your task is to write the missing methods high and low, which receives the integers user inputs as parameters and return the highest and lowest integers respectively.
import java.util.Scanner; public class HighLow { public static void main(String[] args) { int number1, number 2, number 3, high, low; Scanner reader = new Scanner(System.in);
I am trying to write a java application that displays composite numbers between 1 and 100. Here is the format of my code:
//a java application that prints out composite numbers that range from 1 to 100 public class printcomposites{ public static void main(String[] args){ int num=0; int i=0; String printcomposites=""; for(i=1; i<100; i++)
[code]...
My code compiles with no errors, but my code generates every integer between 1 and 100 instead of integers that are composite: