I got a phone number problem. I get a list of phone numbers and a word file containing words, how could I need to see if I could match the phone number to 7 letter words, then see if I can match the first 3 numbers to 3 letter words and then the last 4 numbers to 4 number words. I figured all that out so far. The last part of this assignment is to see if I could match a combination of words together to match the phone numbers.
SO for my project, we have to create a program where we input two four letter words, and using a list of words our teacher provided us and only changing one letter at a time, make the words match.For example, you input BALD and CALL and it would output BALD BALL CALLWe have to use recursion to do this, and I'm totally lost as to where to even begin.
I am trying to validate the phone number with a method called isValidAddress and whenever it gets to that line of code in the while loop I get a lot of red line java exceptions. I am referring to lines 130-138
I had to write a program for class using the method definition "public static char getNumber(char upperCaseLetter)" It compiles and runs but wont print out my final answer.
import java.util.Scanner; public class Phone_0104730303 { public static char getNumber(char upperCaseLetter) { char return_val = 0;
I'm trying to write a method that returns a number, given an uppercase letter as follows:
public static int getNumber(char uppercaseLetter)
The program is supposed to prompt the user to enter a phone number as a string. The input number may contain letters. The program translates a letter (upper- or lowercase) to a digit and leaves all other characters intact.
My code is below:
import java.util.*; public class PhoneKeypad { public static void main(String[] args){ System.out.print("Enter a string: "); Scanner input = new Scanner(System.in); String phNumber = input.next();
[Code] ....
I am getting these errors: java.lang.ClassFormatError: Duplicate field name&signature in class file Chapter9/PhoneKeypad at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
I am trying to make a phone number generator. I get the following error though when trying to compile.
my post
C:JAVA_PROGRAMMING_CODEcode1RandomPhoneNum>javac RandomPhoneNum.java RandomPhoneNum.java:23: cannot find symbol symbol : method toOctalString(int) location: class RandomPhoneNum strippedNum = toOctalString(num1); ^ 1 error
Here is the code so far
import java.util.Random; public class RandomPhoneNum { public static void main(String[] args) { System.out.println("This app prints out a random phone number.");
[Code] ....
Also, how did you people know about octal base numbers? I would never have known that. What I can do to improve my math ability?
I am new to java, and now i have an assignment. I have to parse a phone number like this--> (656) 345 6544 to 6563456544. I've writen the following code that works great with a while loop. Now i would like to know how can i make it work with a for loop.
and the code is import java.io.*; public class Tema { public static String removeChar(String str, int i) { String first= str.substring(0,i);
I'm trying to output a ten digit phone number as a string on one file, and write another program to write it as a long because I don't know what value I need to use in order to get the code to run properly on either one.
Instruction: You work for a telemarketing company and you are required to write a JAVA program that will generate a random phone number. (talk about a real-world application)
-The phone number should consist of 10 digits -The first 3 are the area code and should not begin with 0, 8 or 9 -The second 3 digits should not be greater than 742 and not less than 100. -The last 4 digits can be any digits -Print the number using the following format: "(xxx)-xxx-xxxx", this way it will look like a real phone number (use decimal formatting)
by this : Generating Random Numbers Using arithmetic operations
I've been working on a personal project again in Unit 3 of my text book and this time they want me to make a random phone number generator. Here's the actual directions:
"Write an application that creates and prints a random phone number of the form XXX-XXX-XXXX.
Include the dashes in the output.
Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742.
Think through the easiest way to construct the phone number. Each digit does not have to be determined separately."
With this assignment I came across 2 problems:
1. What I tried was that since the first 3 numbers have to be a random number with no 8's or 9's I tried doing this algorithm:
The problem is that Java won't allow me to generate random numbers this way. Are there any easier ways of generating numbers that doesn't contain specific number (such as 8 or 9 in this case?)
2. I was thinking about this throughout the whole project and what if I generate a number such as 27 (less than 3 or 4 digit number) rather than 3 or 4 digit numbers? How would it show 0027 or 027 instead of 27 for the phone numbers?
import java.util.Random; public class pp0303 { public static void main (String[] args){ Random generator = new Random(); int first0, first1, first2, second, third, random0;
[Code] ....
RESULTS:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: Cannot invoke replace(char, int) on the primitive type int Cannot invoke replace(char) on the primitive type int Syntax error on token "random0", delete this token at pp0303.main(pp0303.java:15)
I have this program where I'm supposed to fill an array with 1000 indices with 1000 randomly generated numbers between 1 and 1000. The program is supposed to check if any of the numbers match an index that is the same value (so for example, the number 4 is in index 4). How to check for that condition, especially using a binary search (I'm also told to use a binary search).
Right now the variable index isn't initialized because I don't know what to initialize it to exactly. How do I check to see if any numbers match the value of the same index?
import java.util.*; public class Identity { public static void main(String[] args) { int [] integers = new int [1000]; // Fill array with randomly generated numbers int [] display = GenerateRandom(integers);
I have a Database with Data of people (name, adress, phone number).
If a user enters a phone number (CLIENT) -> the correct person with the name and adress should appear.
I build up the infrastructure and now I'm at the point that I have to create a Webmethod for it. I just worked on projects like addition of two integers, hello "name", ... I think this example now is harder, BUT i can learn a lot!
I'm trying to figure out the correct way to replace number into letter. In this case, I need two steps.
First, convert letter to number. Second, restore number to word.
Words list: a = 1, b = 2, f = 6 and k = 11.
I have word: "baafk"
So, for first step, it must be: "211611"
Number "211611" must be converted to "baafk".
But, I failed at second step.
Code I've tried:
public class str_number { public static void main(String[] args){ String word = "baafk"; String number = word.replace("a", "1").replace("b","2").replace("f","6").replace("k","11"); System.out.println(word);
[Code] .....
Result for converting to number: baafk = 211611 But, result for converting above number to letter: 211611 = bkfk
What do I miss here?
How to distinguish if 11 is for "aa" and for "k"? D
I'm trying to figure out the correct way to replace number into letter. In this case, I need two steps.
First, convert letter to number. Second, restore number to word.
Words list: a = 1, b = 2, f = 6 and k = 11.
I have word: "baafk"
So, for first step, it must be: "211611"
Number "211611" must be converted to "baafk".
But, I failed at second step.
Code I've tried:
public class str_number { public static void main(String[] args){ String word = "baafk"; String number = word.replace("a", "1").replace("b","2").replace("f","6").replace("k","11"); System.out.println(word);
[Code] ...
Result for converting to number: baafk = 211611
But, result for converting above number to letter: 211611 = bkfk
How to distinguish if 11 is for "aa" and for "k"? Do you have any solutions or other ways for this case?
I wrote a java application that coverts number grades to letter grades. Here is what it looks like:
/java application to That corresponds the letter grade with the number grade import java.util.Scanner; //program uses the class scanner public class gradescore{
Working on my java skills. The is Delimiter function is suppose to return true if there is a delimiter in the string and false otherwise. The main is suppose to call this function and count the number of words in the string:
Here is what I came up with:
import java.util.*; public class NumberOfWordsInString { public static void main (String[] args){ Scanner in= new Scanner (System.in); String s;
[Code] ....
Somehow my method isn't being successfully called by my main and the following error msg was received:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
length cannot be resolved or is not a field
The method isDelimiter(char) in the type NumberOfWordsInString is not applicable for the arguments (char[])
at javaimprovements.NumberOfWordsInString.main(Number OfWordsInString.java:10)
line 10: char ch [] = new char [s.length];
and the main doesn't call the isDelimiter function
String temp = "hi this sf hello is new what is this"; String[] cmd = temp.split("s"); int num = cmd.length; System.out.println("number of words are: "+num); mh_sh_highlight_all('java');
However, when i get the input from user , i didnt get the expected result:
Java Code:
System.out.println("Enter the input string to count the words: "); String[] cmd = new Scanner(System.in).next().trim().split("s"); int num = cmd.length; System.out.println("number of words are: "+num); mh_sh_highlight_all('java');
Write a program that translates a number between 0 and 4 into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B. Break ties in favor of the better grade; for example 2.85 should be a B. Use a class Grade with a method getNumericGrade. why when I type .3 it tells me "Exception in thread "main" java.util.InputMismatchException" Or if there is an easier way to do this.
import java.util.Scanner; public class Grades { public static void main(String [] args) { System.out.println("Enter a number between 0 and 4"); Scanner input = new Scanner(System.in);
I am having some trouble with this program. The assignment is to write a program, given a seven-digit phone number, uses a PrintStream object to write to a file every possible seven-letter word combination that corresponds to that number. I have to avoid using 0 or 1. Here is my code.
import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Scanner; public class TelephoneGenerator { String phoneNumber; char numberLetters[][] = {
[Code] ....
I am getting an error dealing with the main class.
I have a problem with functions connected to strings.
I have a random String, e.g. "Hello World!" and I have to change every capital Letter into a small letter and vise versa. This alone would be fairly simple, but I have to do it with two other strings.
lowercase= "abcde...z" and
uppercase="ABCDE...Z". Every small letter stands at the very same position as the capital letter, but in the other string.
There should be a letter for letter search in lowercase and uppercase for the letters of "Hello World".
How I could solve the task, however I need a way to search the first string, here "Hello World", according to position. A statement which does: "Give me the letter of position x". This found letter should be able to be stored in a variable or else be able to be used by another statement. And it should be compatible with a for lope.
Example : I have code and name but my code must start with the first letter of the inputed name if the 2 input is match it will be inserted into database
code = "A"001 name ="Angela" = success this will inserted into database
else
code ="B"002 name="Angela" =failed this will not inserted into database
else
code="A"003 name="Andy" =success still accepts the input cause they have diff code number
What I am thinking on this was compare the code the name? if == it will be inserted but how do i get the 1st letter of the input name?