Division Of Two Numbers In Java And Show Reminder

Jun 11, 2014

This is my code so far, how can I improve to show the reminder of the operation as well.

package calculator4;
import java.io.*;
public class divide
{
public int num2;
public int num1;
public static void main(String args[])

[Code] ....

View Replies


ADVERTISEMENT

Weed Out All Prime Numbers Without Using Any Kind Of Division?

Dec 15, 2014

The challenge is to weed out all the prime numbers without using any kind of division (%, /). My code doesn't weed out certain numbers, such as many multiples of 5, the number 49, etc, and I am not sure why. Here is my code.

My logic for the for loops was this: Starting with the upper numbers of the ArrayList, find every number that is a multiple of that number and remove it from the ArrayList. Every time you find a multiple, increase the variable multiply, so the program knows what the next multiple to look for.

// program doesn't work yet.
import java.util.ArrayList;
// import java.util.ListIterator;

public class Sieve2
{
public static void main(String[] args)
{
int upperLimit = 55;
ArrayList<Integer> primes = new ArrayList<Integer>();

[Code] .....

And this is the output:

1 2 3 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55

View Replies View Related

Java Communication With Hardware - Show Output In Numbers And Letters

May 29, 2014

I want to make project about java communication with hardware (wiz110sr) via LAN (Rj45). And for example, my hardware have ip address 198.168.0.1 ; port: 1202, connected with my PC(via lan/Rj45). I want show the output (such as numbers and letters) from my hardware in console netbeans.

When I running my code, appear :

" Exception in thread "Thread-0" java.lang.RuntimeException: Uncompilable source code
at mypkg.startListenForTCP$1.run(startListenForTCP.ja va:48)
at java.lang.Thread.run(Thread.java:745)
BUILD SUCCESSFUL (total time: 1 second) "

Here's the code :

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import sun.rmi.runtime.Log;
 
[Code] .....

View Replies View Related

Java Coding For Block Division

Feb 7, 2014

I'm doing project in area of "Cryptography and Network security". I'm having a file with binary Unicode (mean file contain Unicode value of corresponding data (text file)), want to divide that as blocks with the size of 144bits.

View Replies View Related

Java Calculator - Multiplication And Division

Apr 24, 2015

I am having problems with my code I have added the multiplication and division but they will not display also how can I correct any error when dividing by zero?

import java.awt.*;
import java.awt.event.*;
public class calculator2 extends java.applet.Applet implements ActionListener {
TextField txtTotal = new TextField("");
Button button[] = new Button[10];

[Code] .....

View Replies View Related

GUI Show ODD Numbers

Dec 3, 2014

I want to make app in netbeans. When i write numbers in JTextField like 1,2,3,4,5,6... it should show me in JOptionPane information window result of ODD numbers.

View Replies View Related

How To Do Division With Remainder

Apr 24, 2014

I wanna to know how to do division with remainder Presented as xry where x is result of the division

And y is the remainder like 9 % 3 = 9r3

View Replies View Related

Block Division In Cryptography

Feb 20, 2014

I have used FileInputStream class but its not working properly to divide the bits into blocks.I will attach the coding

public static void main(String[] args) {
 ReadFileExample newclass = new ReadFileExample();
System.out.println("cryptography");

[Code].....

View Replies View Related

Count The Number Of Division That Occur

Feb 4, 2015

I am using count++ in my program in order to count the number of division that occurs. It works but outputs:

The number of divisions is 1
The number of divisions is 2
The number of divisions is 3
The number of divisions is 4
The number of divisions is 5

All i want is the last line. How do I solve this?
 
import java.util.Scanner;
public class Program3
{
public static void main(String [] args)
{
int div;

[Code] ....

View Replies View Related

New Lines Don't Show Up In File But They Do Show Up On Console

Apr 30, 2015

I have the following code.

class A {
List<StringBuilder> list;
public void output(List<StringBuilder> objectToOutput){
try(BufferedWriter bw = new BufferedWriter(new FileWriter("temp.txt"))){
for(StringBuilder row:objectToOutput) bw.write(row.toString());
}catch(IOException e){}

[code]....

Why don't the a's show up on the console? I put them in as part of the debugging process and now I don't understand why they don't show up in both places.

View Replies View Related

Getting A Algorithm Format Of Butterfly Sub Division Technique?

Jul 16, 2014

Here is the Butterfly sub division technique which refines the mesh of a STL file.I have to prepare a java code based on this technique, give the step by step procedure or algorithm for this.(files attached)

View Replies View Related

Multiplication Worked But Division Didn't Work

Mar 5, 2014

I was trying to execute the following program and the multiplication worked but the division didn't work.

import java.util.Scanner;
public class BodyMassIndex {
public static void main(String[] args) {
// Prompt the user for weight and height
// Create a scanner
Scanner input = new Scanner (System.in);
System.out.println("Please enter your weight in pounds");
int weight = input.nextInt();
System.out.println("Please enter your height in inches");
int height = input.nextInt ();
double BMI = weight * (0.45359237)/ (height * 0.0254)*(height * 0.0254);
// the weight * (0.45359237) executed but it wasn't divided by (height * 0.0254)*(height * 0.0254)
System.out.println ("Your BMI is "+BMI);

View Replies View Related

Making Time Calculator Work / Modulo Division Not Working

Oct 22, 2014

Prompt for the project is "Write a program that will ask the user for a number of seconds and output the equivalent period of time in days, hours, minutes, and seconds.The program should:

-Use modulo division to calculate the number of days, hours, and minutes.
-Use compound operators when making assignments.
-Proper formatting and use of comments
-Symbolic constants defined as the number of seconds in a minute, hour, and day.

For example: final int sec_in_min = 60;"

public class Mod1
{
public static void main (String[] args)
{
int sec, min, hr, day;
final int SEC_IN_MIN = 60;
final int SEC_IN_HR = 60 * 60;
final int SEC_IN_DAY = 60 * 60 * 24;
 
[code]....

View Replies View Related

How To Show AEST / AEDT In Java Timezone

Dec 10, 2014

In my application I need to print timezone abbreviation based on location. But fot Australia it is showing EST, even though my time zone data file version is tzdata2014i. I read that from version tzdata2014f, java supports AEST/AEDT but I don't see this in tzdata2014i.
 
How to get AEST/AEDT timezones.

View Replies View Related

Show System Tray Or Desktop Notification From Web Application Based On Java

Nov 23, 2014

The explanation is a bit lengthy because I just tried to explain everything in one shot.

Link to the question

java - Show a System Tray notification or Desktop notification from the web application

View Replies View Related

Make Date Column Show Only Date And TimeIn And TimeOut Column Only Show Time

Mar 11, 2014

How do i make the 'date' column show only the date and 'timeIn' and 'timeOut' column only show the time. In my database table my 'date' column is a date type and 'timeIn' and 'timeOut' column is time.

View Replies View Related

Java Program To Add Two Numbers?

Jan 30, 2014

I want to develop an simple application using java for a simple porgram for the addition of two numbers.

View Replies View Related

High Numbers In Java?

Sep 3, 2014

i want to make an application that use vers high numbers, but can int, double, float, or long do that for me?

View Replies View Related

Reversing Numbers Entered (in Java)

Mar 29, 2014

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."

View Replies View Related

How To Print All Numbers Of Array In Java

Jan 1, 2015

This is my code

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)

[code]....

and i am getting this output

----------
! 1712 !2156|
----------
! 1713 !4583|
----------
! 1714 !3981|
----------

[HENRY: 6000+ LINES DELETED -- Isn't it a bit ridiculous hard to read when you flood a post with thousands of output lines?]

----------
! 4998 !3094|
----------
! 4999 !836|
----------
12:10:56

I am expecting Number to be print from Index ) but they are not printing ,why?

If I use arraysize like 2000 I am getting all number starting from 0 to 1999 .why?

View Replies View Related

Java Calculator - Numbers Are Not Adding

Jul 12, 2014

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.

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

[Code] .....

View Replies View Related

Making Plus Sign To Add Two Numbers In Java

Mar 7, 2015

I am having a bit of trouble making the '+' add two numbers in java. For example:

When the user enters " + 4 5 " I want it to come out as " 4.00e+00 + 5.00e+00 = 9.00e+00 "

Here is what I have so far:
 
public static void main(String[] args) {
 Scanner in = new Scanner(System.in);
 while (in.hasNextDouble()) {
 double num1 = in.nextDouble();
double num2 = in.nextDouble();
String s = "";
 
[Code] .....

View Replies View Related

Reverse Numbers Using Java Arrays

Feb 27, 2014

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: ");

[Code] .....

View Replies View Related

Regular Expression In Java Which Allow Only Numbers

Nov 28, 2013

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;

[Code] ....
 
but this is allowing characters like a,b,c..

View Replies View Related

Why There Is No Literal Representation For Binary Numbers In C / C++ Or Java

May 25, 2015

in Operator/Literals, it says "There is no literal representation for binary numbers in C, C++, or Java." seems "0b11001" could reprensent binary numbers?

int i = 0b100;
System.out.println(i);

the output should be 4.

View Replies View Related

Printing Highest And Lowest Of Three Numbers Using Java?

Feb 23, 2014

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);

[code]......

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved