Find ASCII Number Of Names Entered

Sep 12, 2014

I am having a problem with SD array .i have to find the ASCII no. of names entered.

import java .io.*;
class ASCII
{
public static void main()throws IOException
{
InputStreamReader read = new InputStreamReader(System.in);

[Code] .....

View Replies


ADVERTISEMENT

Find If Number Entered By User Consecutive Or Not

Feb 21, 2014

I need to find if the number entered by the user are consecutive or not!

Ex:this should return a true!! This should return false!

(1,2,3) (3,5,7)
(3,2,4) (1,2,2)
(-10,-8,-9) (7,7,9)

My program seems to work ok when i enter number in order like 1,2,3 = true , and all the numbers for false seem to be working as well! my problem is when i enter number like 3,2,4 that are not in order but still are consecutive!! I thought that another if statement would be the solution but i have tray several different ones and still can't make it work !!!

Java Code:

import java.util.*;
public class Consecutive{
public static void main (String [] args){
Scanner console= new Scanner(System.in);
System.out.println("Enter three numbers");
String numbers = console.nextLine();

[[Code] .....

View Replies View Related

How To Initialize To First Number Entered

Aug 10, 2014

initialize the min and max to be the first numbers entered, need to improve the code, because if the number entered is < 0 there is an error. but i dont understand how i would initialize to the first number entered, my understanding is tha if the user enters a 5 , then i should initialize to value 5, but i cant anticipate what the user will enter. I could initializa to null, but that still is not the first number entered.

int min = 0;
int max = 0;
int option = JOptionPane.YES_OPTION;
while ( option == JOptionPane.YES_OPTION){

[code]....

View Replies View Related

If Statements - Each Number Entered In Greater Than Zero

May 9, 2014

write a program that will ask the user to enter five numbers.using If statements if each number entered in greater than zero

import.java.util.Scanner;
public class Java3 {
public static void main(String[] args) {
function addNumbers(n1, n2, n3, n4, n5){
var finalNumber = 0;

[Code] ....

addNumbers(1, 2, 3, 4, 5,);

View Replies View Related

JSP :: How To Format Entered Number On Textbox

Apr 24, 2014

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatNumber type="currency" value="12345.6789"/></p>
<input type = "text"/>

This one is working if i set value in fmt but what i want to happen is when i enter a number in textbox it will be fommated on the format that i want, so i think i need to an of og text and set it into value of fmt? <y plan is when I enter a number in textbox it will automatically formatted ....

View Replies View Related

Write Program To Sort Names According To Number Of Vowels?

Feb 15, 2014

write a program to sort names according to number of vowels sort({sam,ratan,alok,raj}) the op is {sam,ratan,alok,raj}

View Replies View Related

Allow Input To Loop Until 0 Is Entered For Product Number

Sep 15, 2014

What I am trying to do here is allow input to loop until 0 is entered for the product number. When 0 is entered, it should then dump the total for each individual product. I've tried it about a dozen different ways and have yet to be able to get the loop to function as intended. The way I have the code below, the loop will not function at all (where as before it looped, but never finished).

import java.util.Scanner;
public class Sales {
public static void main(String[] args) {
double total1=0.0;
double total2=0.0;
double total3=0.0;
double total4=0.0;
double total5=0.0;
int product;

[Code] ......

View Replies View Related

Math On Three Numbers - Get Average / Sum And Number Entered By User

Feb 25, 2015

Java program : For this assignment you are going to write code for the following class:

MathOnThreeNumbers

Here are the specifications of class MathOnThreeNumbers:

Methods of class MathOnThreeNumbers:

1. inputThreeNumbers
2. getAverage
3. getSum
4. getNumberOne
5. getNumberTwo
6. getNumberThree

Constructor of class MathOnThreeNumbers

write a constructor that initializes the first, second, and three numbers to 1, 2, and 3 respectively.

Specs for the methods methods:

1.
name: inputThreeNumbers
accessibilty: public
arguments: none
what it does: asks the user for three numbers of type double

2.
name: getAverage
accessibilty: public
arguments: none
what it does: returns average of the three numbers

3.
name: getSum
accessibilty: public
arguments: none
what it does: returns sum of the three numbers

4.
name: getNumberOne
accessibilty: public
arguments: none
what it does: returns the first number entered by the user

5.
name: getNumberTwo
accessibilty: public
arguments: none
what it does: returns the second number entered by the user

6.
name: getNumberThree
accessibilty: public
arguments: none
what it does: returns the third number entered by the user

Here is an example of how the class MathOnThreeNumbers works. The following code produces the output displayed after the code.

MathOnThreeNumbers mm = new MathOnThreeNumbers();
System.out.println("first: " + mm.getNumberOne());
System.out.println("second: " + mm.getNumberTwo());
System.out.println("third: " + mm.getNumberThree());
mm.inputThreeNumbers();

[Code] .....

View Replies View Related

Take User Input And Display Sum Of Digits Of Entered Number

Nov 6, 2014

I have returned with yet another problem but I think this one might be a bit easier to fix.

So the whole MO of this program is to take user input, and display the sum of the digits of the number they entered. I am supposed to do this by utilizing methods. So far this is what I have and when I compile it tells me that it "cannot find symbol", which I don't understand as I define what "m" is in the for loop. The other error is that it says:

"Exercise6_2.java:22: error: incompatible types: possible lossy conversion from long to int
return result;
^

I don't understand why it's giving me this error nor do I understand why result seems to inherently be an int. (Also the public static int sumDigits(long n) method was given to me by the book so that is what I am supposed to use).

import java.util.Scanner;
public class Exercise6_2 {
public static void main(String[] args) { 
Scanner input = new Scanner(System.in);
System.out.println("Enter a integer");
long n = input.nextLong();

[Code]...

View Replies View Related

Read Integer From Keyboard Until Negative Number Is Entered

Apr 8, 2014

Basically i have a question ask me to write a program that read integer from keyboard until a negative number is entered, and then print out the max and min out of the number i have entered.

This is what i have done already which works, but i need to ignore the negative number when print out max and min...which i dont know how to do so. when i compile this program now it will always give me the negative number i enter at the end as minimum. which i need to ignore

Also if negative number is entered at once the program should print a error message say max and min are undefined.

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
int large = Integer.MIN_VALUE;
int small = Integer.MAX_VALUE;
while(true) {
System.out.print("Enter a integer: ");
int n = in.nextInt();

[Code] ....

View Replies View Related

Simple For Loop - Determine Factorial Of A Number Entered By User

Jun 28, 2014

I'm trying to learn Java and my current project is to write a short program to determine the factorial of a number entered by the user. I haven't looked. There may be a method that will do it, but I want to use a for loop specifically.

What I have compiles just fine. I'm actually pretty thrilled just with that. Here is what I have:

class factorial {
public static void main( String[] args) {
Scanner scan = new Scanner(System.in );
int num;
int product = 1;

[Code] ....

View Replies View Related

Store Name SD Array And Display Room And Floor Number Whose Name Is Entered

Sep 12, 2014

I have to store the name SD array and display the room and floor no. whose name is entered but i am having a problem with the logic part. The answer is coming to be wrong

import java .io.*;
class hotel
{
public static void main()throws IOException {
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
String ar[][] = new String[5][10];

[Code] ....

View Replies View Related

For Loop To Convert Any Number Entered To Base 10 With Any Base Provided

Oct 9, 2014

So i'm writing a for loop to convert any number entered to base 10 with any base provided as well. My code does not work because I need a way to reverse the code order, so the new number is printed correctly with the given base. My code so far:

public static void main (String[] args) {
Scanner kb = new Scanner (System.in);
System.out.print("Enter a number :: ");
int numOriginal = kb.nextInt();
System.out.print("Enter a base :: ");
int base = kb.nextInt();

[Code] .....

newBase has a problem with how it calculates the new number, looking for correct newBase code for conversion?

View Replies View Related

Find The Lowest Number?

Apr 12, 2014

I have to find the average, highest, and lowest numbers in an array. I already have the average and highest, and I thought I could find the lowest number the same way I found the highest, but it's not working. It just keeps coming out to 0. I've tried out different ways, but I want to see if there are better ways than doing MAX_VALUE for the lowest, then looping it through.

import java.util.Scanner; 
public class Test_Scores {
public static void main(String[] args) {
//array,scanner,values

[Code].....

View Replies View Related

Find Number And Sum Of All Integers

Oct 29, 2014

Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7.

View Replies View Related

How To Find Whether A Number Is Palindrome Or Not

Aug 6, 2014

Any simplest code to check whether a number is palindrome or not?

View Replies View Related

Find Day Number Of The Year?

Apr 15, 2014

figuring out the logic to print the day number of the year. The directions for my homework are: Write a program that prints the day number of the year, given the date is in the form: month day year. For example, if the input is 1 1 05, the day number is 1; if the input is 12 25 05, the day number is 359. The program should check for a leap year . I have a basic outline of the program but i am having trouble with figuring out the logic to display the day number of the year given the date. This is what i have so far

import javax.swing.JOptionPane;
 public class Practice4 {
public static void main(String[] args){
String monthStr;
String dayStr;
int inputMonth;

[code]....

View Replies View Related

Find Slot Number In Array?

Jan 30, 2015

what I needed to know to complete the lesson, but now it just tells me what the output should be and I have to research the information on my own. anyways, here is my code from the previous lesson:

import java.util.Random;
import java.util.Scanner;
public class tnArray {
public static void main(String[] args) {
int [] array;

[code]....

Now I have to change it so that instead of counting the number of times a number will appear in the array, I must output which slot in the array the number is in.

View Replies View Related

Find Number Of Rows In CSV File

Feb 13, 2014

I am working through a text and I am supposed to complete the following tasks.

Your ReadFiles.java class requires the following methods:

Method: check to see if the file exists

Method: find number of rows in csv file

Method: Converts the csv file to a mutli-dimensional array

Method: PrintArray

Method: Return array using a get method

Create a file DataAnalyzer.java. This file will be used to call the methods in ReadFiles.java. Be sure to demonstrate that all of your methods work through DataAnalyzer.java.

The problem is that it does not really provide any information on how to go about reading a file into an array. I am stuck at the third task of converting the file to an array and I have tried several ways to do this unsuccessfully. I thought that I would at least try to get things to print out (line 87) to see if I could get that to work, but all that prints in null over and over again.

Java Code:

public class DataAnalyzer {
public static void main (String[] args) {
ReadFiles aReadFiles = new ReadFiles();
aReadFiles.fileCheck();
aReadFiles.findRows();
aReadFiles.convertFile();

[Code] .....

View Replies View Related

Find Biggest Number From Array

Jun 26, 2014

I have 2 arrays in random order of 10 numbers.I need to find the biggest number from array A and B and then when its on a screen second thing is to multiply those numbers by 2.

import java.util.Random;
public class Projektas {
public static void main(String arng[]){
int i,j;
int A[] = new int [10];
int B[] = new int [10];;

[code]..

View Replies View Related

Java Math - Find Imaginary Number

Nov 2, 2014

I am doing this math for my assignment where you have to find the imaginary number.

double dem = (b*b-4*a*c)*-1;
double dem2 = Math.sqrt(dem);
realPart = (-b/(2*a));
imagine = (dem2)/(2*a);
imagineneg = (dem2)/(2*a);

So basically I am trying to get it that the number inside the square root isnt negative. So lets say I enter a: 1, b: -1, c: 4.25. When you do the discriminant it would be -16 but I want that to be positive so I multiple it by -1 (thats the dem part). Then I sqaure root the whatever the answer is and then go to the imagine and imagineneg part where you find the imaginary number.

My problem is that instead of it being -16*-1 to get 16, some how I get 15.

View Replies View Related

How To Find How Many Times A Number Appears In Array

Dec 7, 2014

This is my code up to now and I can't do anything to make it work. I want it to tell me how many times the number 3 appears, and the last position it was in. I am getting errors like"Cuanto.java:88: getPosition(double[],double) in Cuanto cannot be applied to (double) ....

a = getPosition(a);" and unreachable statements, and value not found. It's all over the place every time I make a change to it.

Java Code:

public class Cuanto {
static int getPosition(int count,double listOfValues[],
double targetValue) {
int a = 0, i;
for (i=0; i < listOfValues.length; i++) {
if (listOfValues[i] == targetValue) {
a++;

[Code] ....

View Replies View Related

Java - Find Number In Given Array Of Integers

May 2, 2014

I wrote this simple piece of code to find the number in the given array of Integers. The program works fine although it shows a couple of errors when i modify it a little bit.

public class DemoLabel{
public static void main(String [] args){
int[][] arrofInts={
{32,45,67,87},
{23,44,55,66},
{12,47,87,56},
{23,44,12,78}

[Code] .....

In the disp() method,Suppose i only want to pass two arguments i.e disp(i,j) given that searchFor variable is visible in the entire class but when i use disp(i,j) i get the following error

DemoLabel.java:38: error: cannot find symbol System.out.println("The number "+searchFor+" is at the location"+i+" , "+j);
^
symbol: variable searchFor
location: class DemoLabel

So i decided to declare the

int searchFor
as
public int searchFor

But the compiler threw another error saying that it was a Illegal start of expression

Also,when i add a SOP line after the label search: it shows the error

DemoLabel.java:25: error: undefined label: search
continue search;
^

Although i got the program to work it would be useful if i could understand why it doesn't work with the modifications.

View Replies View Related

Find Number Of And Sum Of All Integers Greater Than 100 And Less Than 200 Divisible By 7

Oct 30, 2014

 Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7.

View Replies View Related

Find Biggest Corner Based On Number Zero

Apr 23, 2014

The program should find the biggest corner, based on the number zero.

A zero becomes a corner when there's the same amount of zeros under it, and left to it.

The program should print a message saying what's the biggest corner size.

Corner size is the number of zeros inside it.

Java Code:

import java.util.*;
class Corners
{
static Scanner reader=new Scanner(System.in);
static final int N=25;
static int corners(int a, int b, int[][] m)

[Code] ....

That's the output:

Java Code:

The BOX:
1 0 0 1 1 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 1 1
1 0 1 0 1 0 0 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 1 1 0
0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 0 0 0
0 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 1
0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0

[Code] ....

View Replies View Related

Find The Column With Highest Average Number

Feb 14, 2015

code a 10 * 10 matrix, with random numbers from 1 to 100,

i) Find the most repeated number.
ii) Use the Binary Sort, to sort the matrix in ascending order.
iii) Find the Column, with the highest average number.

View Replies View Related







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