Accept Compass Directions And Display The Same
Jan 29, 2015
A program to create a class that contains a method that accepts compass directions and displays the same. You need to ensure that the method must accept any one of the directions: NORTH, SOUTH, EAST, WEST, NORTHEAST, SOUTHEAST, SOUTHWEST or NORTHWEST.
View Replies
ADVERTISEMENT
Apr 14, 2014
This program is supposed to accept an integer as an input and display the message that the number is even or odd. The main method calls a Boolean method. Write a method private static boolean iseven(int number and the message is printed from the Main method. This is what I have.
import java.util.Scanner;
public class OddorEven {
int number;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
[Code] ....
I know the message is not being printed from the Main method. I'm not sure how to do that.
View Replies
View Related
Jan 23, 2015
The program is to accept a string and display all the palindrome words(the words that are same even if they are reversed-------->mom,madam,malayalam etc.)in the string.
I need to solve this program urgently.
There are no syntax errors but after typing in the sentence,no output is displayed. This is my program....
import java.util.*;
class palindrome_test
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter a sentence");
String usersInput=in.nextLine();
[Code] .....
View Replies
View Related
Nov 16, 2014
I've been looking through the Java API for a component similar to the direction selector compass in google earth (the one that acts like a circular scroll bar) to no avail. Any existing component before breaking down to creating the component myself.
View Replies
View Related
Apr 15, 2015
Write a menu driven program that either accepts words and their meanings, or displays the list of words in lexicographical order (i.e. as in a dictionary). When an entry is to be added to the dictionary you must first enter the word as one string, and then enter the meaning as separate string. Another requirement - from time to time words become obsolete. When this happens, such word must be removed from the dictionary.
Use the JOptionPane class to enter the information.
Use the concept of linked list to carryout this exercise. You will need at minimum the following classes:
- A WordMeaning class that hold the name of a word and its meaning.
- A WordMeaningNode class that creates the node of information and its link field.
- A WordList class that creates and maintain a linked list of words and their meanings.
- A Dictionary class that test your classes.
For the output, the program should produce two scrollable lists:
- The current list of words and their meanings.
- The list of the deleted words. You need not list the meanings, just the words.
So far, I have everything coded except for the remove method, and I am not sure how to code that. I coded the add method already, but now I don't know where to begin with the remove method in my WordList class. My classes are below.
WordMeaning Class:
public class WordMeaning {
String name;
String definition;
WordMeaning(String t, String d) {
name = t;
definition = d;
[Code] .....
View Replies
View Related
Dec 29, 2014
ex
Sample input:2340980
Sample Output:23498
this is the program i have tried but is dosent work
import java.util.*;
class zero
{
public static void main(String args[])
{
[Code]....
View Replies
View Related
Mar 13, 2015
I am making a program which will have the user enter their location (by postcode) into the GUI (Swing).
I want to use Google's Directions API [URL] .... to find directions from this user input address to another address. However, I have never gone about using external APIs before and even going as far as installing the necessary files on my system to get started is getting complicated.
How do I go about using this API in my own application? I have tried following the tutorials (e.g. [URL] .....) but I suspect I may even be using the wrong tutorial (I am seeing references saying that the client thing is depreciated).
View Replies
View Related
Jul 5, 2014
I have a GUI with a JTextField. I need to check that the input entered by the user is made up of only integers.
For example I accept: 1, 10, 530, ...
I do not accept: -10, 1.5, -6 ...
I would like to implement this control by using a regular expression so I would have a code like that.
JTextField text = new JTextField();
String input = text.getText();
boolean bool = checkInteger(input);
if(bool)
System.out.println("Ok");
else
System.out.println("Error");
The checkInteger(String input) method should check if the input string is correct or not.
How can I do to implement this control with regular expressions?
Is there an easier way to do it?
View Replies
View Related
Oct 24, 2014
A friend and I are working on a project in which we must test "super anagrams" (anagrams in which all characters in the first string are found in the second). We have a driver and definitions class pasted below:
Definition
class SuperAnagram{
String left = new String("");
String right = new String("");
[code]....
In the driver class, we get "cannot find symbol" errors at the beginning of cleanStrings and isSuper, both inside and outside of the if statement.
View Replies
View Related
Jan 14, 2015
I am trying to create a fortune teller and everything is running fine except the program does not prompt you to answer the questions
Do you like donuts?
and
What did you have for breakfast?
Here is the code this is in Bluej :
import java.util.Scanner;
public class FortuneTeller {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Welcome to Fortune Teller");
[Code] .....
View Replies
View Related
Feb 2, 2014
Basically, I'm just trying to let the user enter the name. It crashes whenever the input isn't an int. Also, here's the bit of code I'm using that has to do with that. I don't feel like putting the entire class, so here's that bit of code:
PHP Code: String yourName = user.nextLine(); mh_sh_highlight_all('php');
Anyway, I just haven't figured out how. Also, the scanner is called user in this class.
View Replies
View Related
Nov 8, 2014
How can I get enter(return) as empty input from user?!
scanner.next will wait until I input a string ...
But I want it when I hit return sets the variable to empty string ...
View Replies
View Related
Sep 2, 2014
i was reading my book when in a code,it used accept(),but it did'nt talk about it.would you explain to me where to use accept().(the chapter was about socket programming)
View Replies
View Related
Jan 3, 2015
I have a method that accepts as a parameter an object:
public void addClient(Client c){ }
Client is a class which has a constructor that has two String parameters:
public Cliente (String name, String lastname){
this.name = name;
this.lastname = lastname;
}
In the main add a Client in this way:
addClient(new Cliente("first", "second"));
Now, i have an array of Client, so I would like to enter within this. Example:
public void addClient(Client c){
for (int i = 0; i<client.length ; i++) { // client is an array of Client object
client[i] = c; // Enter a c in the array, but does not work!
System.out.println("test "+clienti[i]); // print Client@15db9743
}
}
I have used the println for check if worked insertion, but the result shows no
View Replies
View Related
Jan 6, 2015
I wrote a couple classes and am trying a test driver but it is having an error I do not know how to solve.
Student Class:
public class Student{
private Course[] courseList;
private static int numCourses;
private final int maxCourses;
public Student(int max){
maxCourses = max;
[Code] .....
Error:
javac tester.java
tester.java:6: error: cannot find symbol
one = new Course(name);
^
symbol: variable name
location: class tester
1 error
Same issue, just only one error as there is only one line. It seems like it does not accept my parameters as it cannot find symbol.
I forgot to put the "" in the brackets, it's been a month since I have looked at any java and made this simple mistake.
View Replies
View Related
Aug 26, 2014
I was trying to write a program that will accept values and transform the scores to grade. Like 70 and above will be given A from 60 to 69 is B, from 50 to 59 is C, from 40 to 49 is D and below 40 is F. I have defined the variables, for the textfield, am confused on how make this hapen on just a click of the comand botton.
View Replies
View Related
Mar 13, 2015
I want to write a program that accepts user input and then prints its average in a serial way.
Suppose i enter 5. I should get result 5 first time then i input 10 then it should return the average of (5 and 10) and then i enter say 20 it should return average of (5,10 and 20) and so on.
View Replies
View Related
Jan 28, 2015
I am attempting to write a program that accepts input of a positive integer, reports each digit and then the sum of all digits. This is what I have so far:
*/
package numbersum;
import java.util.*;
public class Week4NumberSum {
static Scanner console = new Scanner(System.in);
/**
* @param args the command line arguments
[Code]...
It works if I enter 1234567891 (10 digits)
Enter a positive integer: 1234567891
digit: 1
digit: 2
digit: 3
digit: 4
digit: 5
digit: 6
digit: 7
digit: 8
digit: 9
digit: 1
The sum of the digits is 46
But if I enter 11 digits, it fails:
Enter a positive integer: 123456789123 (12)
Exception in thread "main" java.util.InputMismatchException: For input string: "123456789123"
at java.util.Scanner.nextInt(Scanner.java:2123)
at java.util.Scanner.nextInt(Scanner.java:2076)
at week4numbersum.Week4NumberSum.main(Week4NumberSum. java:26)
java - Scanner error with nextInt() - Stack Overflow gives me some infor for InputMismatchException - which I find described as In order to deal with this exception you must verify that the input data of your application meet its specification. When this error is thrown, the format of the input data is incorrect and thus, you must fix it, in order for your application to proceed its execution.
I don't understand why the 10 digit integer is OK but the 11 or > digit integer is a mismatch.
View Replies
View Related
Mar 9, 2014
What I'm supposed to be doing is making it so the program can accept multiple filter and sort commands at one time, and each should be separated by a whitespace.I was thinking about parsing the input again, using whitespace as the delimiter, then normally progressing with each token, as though there was only one command.
However, coding this the way I'm doing it will firstly probably take hours, and secondly, it's likely not even right. I don't have any real way to determine which token contains which data from the Song objects.These are the specific requirements for this portion:A sort/filter command consists of one or more of the following options:
-year:<year(s)>
-rank:<rank(s)>
-artist:<artist>
-title:<title>
-sortBy:<field>
Any number of these options may be given, and they may be given in any order. If multiple options are specified, they will be separated by whitespace.
GazillionSongs Class (the main)
Java Code:
import java.util.*;
import java.io.*;
[code]....
View Replies
View Related
Oct 22, 2014
Creating a file upload servlet to accept a CSV and parse for insert into a database, however, whenever I click submit, it always seems to open a new tab/window. Below is the method I have that builds the upload form: (Using GWT 2.4)
private void buildUpload(){
LayoutContainer headerContainer = new LayoutContainer(new ColumnLayout());
headerContainer.setStyleAttribute("padding", "5px");
add(headerContainer);
NamedFrame hiddenFrame = new NamedFrame("uploadFrame");
final FormPanel form = new FormPanel(hiddenFrame);
[Code] .....
Is there something I'm missing? or something I've added that makes it open a new tab/window?
View Replies
View Related
Jun 10, 2014
import java.io.*;
Class bubble
{
public static void main()throws IOException
{
BuffetedReader br=new BufferedReader (new InputStreamReader (System.in));
int j, k, temp;
String st[]=new string [10];
[Code] .....
View Replies
View Related
May 22, 2015
Write a function that accepts an array of non-negative integers and returns the second largest integer in the array.
Return -1 if there is no second largest.
The signature of the function is int f(int[ ] a)
Examples:
if the input array isreturn{1, 2, 3, 4}3{{4, 1, 2, 3}}3{1, 1, 2, 2}1{1, 1}-1{1}-1{}-1
In the signature what I understood is, I should write my function with the given signature,
The return type is "int"
method name is "f"
parameter is "a" right ?
Writing my doubts beside the particular line in the code
public static void main() // In the answer why they didn't use the class ?
In main method why they didn't use parameters ?(String[] args)
{
a1(new int[]{1, 2, 3, 4}); // what is "a1" here is it array name ? this line initializing the array ?
a1(new int[]{4, 1, 2, 3});
a1(new int[]{1, 1, 2, 2});
a1(new int[]{1, 1});
a1(new int[]{1});
a1(new int[]{});
}
static int a1(int[] a) // what is "a" here parameter ? and "a1" is method name ? why they used the array name and method name same ?
{
int max1 = -1;
int max2 = -1;
for (int i=0; i<a.length; i++)
[Code] .....
View Replies
View Related
Mar 25, 2013
We have a requirement that we need to have text area/text box on screen to accept multiple languages like (Spanish and russian) that means user can able to enter their text data either in any language like english,russian and spanish(It should be possible to enter the comments in russian and spanish languages). Is it possible to implement in java/j2ee?
View Replies
View Related
Nov 1, 2014
I am practicing some basic recursion and I was trying to solve this problem
Write a method sumTo that accepts an integer parameter n and returns the sum of the first n reciprocals. In other words:
sumTo(n) returns: 1 + 1/2 + 1/3 + 1/4 + ... + 1/n
For example, the call of sumTo(2) should return 1.5. The method should return 0.0 if passed the value 0 and should throw an IllegalArgumentException if passed a value less than 0.
This is my attempt to do it , however my output is always a 0.0 , and i do not understand why :
public static double sumTo(int n ){
if(n<0){
throw new IllegalArgumentException();
}
else if (n==0){
return 0.0;
[Code] .....
View Replies
View Related
Feb 8, 2015
Write a java program to accept a string, float and an integer as command line arguments. String value should be displayed. Also the program should display the maximum value of two numbers. Use Integer.parseInt() and Float.parseFloat()
View Replies
View Related
Nov 20, 2014
Write a method maxOccurrences that accepts a list of integers as a parameter and returns the number of times the most frequently occurring integer (the “mode”) occurs in the list. Solve this problem using a map as auxiliary storage.
If the list is empty, return 0.
View Replies
View Related