Telephone Number - Write To A File Every Possible Seven-letter Word Combination
Nov 23, 2014
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.
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);
Write a program to calculate the telephone charges for four customers. The data for each customer consists of NAME, PREVIOUS METER READING, PRESENT METER READING. The difference between the two readings gives the number of units used by the customer for the period under consideration.
The amount due for each customer is calculated by: UNITS USED * RATE PER UNIT + RENTAL CHARGE The rate per unit and rental charge is assumed to be the same for all customers and must be input once only.
Your program must:
a. Input the rate and rental charge b. Read the data for each customer and calculate the amount due c. Print the information under suitable headings d. Calculate and print the total amount due to the telephone company
I'm trying to convert the first letter of every word in a String to uppercase. I've managed to isolate the first letter of every word and then make it uppercase but I don't know how to replace it.
public static StringBuffer makeUpperCase(){ String str = String.valueOf(input2); for(int i = 0; i < str.length(); i++){ if(str.charAt(i) == ' '){ char var = str.charAt(i + 1); var = Character.toUpperCase(var); System.out.println(var); } }
The code is supposed to output a word from a sentence(from a sample file) with most frequently occurring letter in that word.
Example input: "Therefore, it is this word."
output: therefore
It currently uses 3 loops nested loops, is there a way to improve this?
public static String findWord(String file) throws IOException { BufferedReader in = new BufferedReader(new FileReader(file)); String text, correctWord = null; text = in.readLine(); StringTokenizer tokens = new StringTokenizer(text.toLowerCase(), " ,.?"); //split string into tokens of words only int count = 0, numLetter = 0;
The game runs fine, however I have to include how many times each letter that is guessed occurs within the word. For example, if the guess is e, the program should print out: The character e occurs in 3 positions. How would I go about doing this??
/* * A program that plays simple word guessing game. In this game the user provides a list of words to the program. * The program randomly selects one of the words to be guessed from this list. * The player then guesses letters in an attempt to figure out what the hidden word might be. * The number of guesses that the user takes are tracked and reported at the end of the game. */
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!
this is the following task i am trying to do. Write an interface Directory to manipulate entries in a telephone directory for the University. The interface must support the following operations:
1) The ability to insert new entries into the directory. Entries should be stored in alphabetical order of surname. 2) Delete entries from the directory either by name or number 3) Provide a lookup method that will find the extension no of a member of staff given his/her name. You should try to make this method run as efficiently as possible. 4) Change a person's telephone number 5) Print the telephone directory in a neatly tabulated fashion.
Write a class ArrayDirectory that implements this interface using an array to store the telephone directory information. The class must store the surname and initial for each member of staff and their telephone extension (a four digit number which may start with a zero). You may find it useful to define a class Entry to store information about individual entries. The entries should be read into the array from a text file consisting of multiple lines in the following format:
Surname<tab>Initials<tab>Telephone extension
The part that i am stuck on is trying to do the entry method, delete entries method, loop up method, change persons telephone number and be able to print it.
The intentions of this program is to prompt a user to enter a file name, and then reads the file. The program will prompt the user to enter a word that needs to be corrected. So lets say I have a text file containing "My name is OP and I Like goind to the Park!" I want to change "goind" to "going",
Now, my second method "isSimilar" executes a similar word with more than one same letter and same length, but I dont know how to execute that whole thing in my third method "correctThisLine" . How I can call that isSimilar method and read in that text file and change that word into that?
import java.util.*; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class WahidMuhammadA3Q2{ String fileName = "AutoCorrectMe.txt"; public static void main (String [] args){
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
How do i write a method in java that will add a <b> or <em> tag to a specific word regardless of case or punctuation for example for "run forest RUN!" adding bold to run would be
<b>run<b> & <b>RUN!<b> public void addTag(String word, String tag) {
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 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.
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{
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?
I was given the assignment of creating a number to word program for my first college java programming homework.
Here is what I have created so far :
import java.util.*; public class PrintNumberInWord { // saved as "PrintNumberInWord.java" public static void main(String[] args) { int number = 5; Scanner sc = new Scanner (System.in); { System.out.println ("Enter a number"); System.out.println(" "); if (number == 1) {
[Code] .....
The first lines were made for us so we could follow a guideline, however, no matter what I type the command prompt displays 5 to me, I know thats because 5 is defined in the beginning but backspacing 5 causes the program not to work at all, how can I get this program to work properly?
any method or common algorithm to change a number taken from input to the word for that number? Such as input being "4", output would be "four", at least up to 59 as the larger program I'm trying to make involves time
My code compiles and runs just fine, i'd just like to get creating a small square box that shows number of words used next to the "word count = ". i'd wanto to press the count words button to count and show the number in the square box. here is my code.
import javax.swing.*; import javax.swing.text.*; import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class wordCount extends JFrame implements ActionListener
i'm trying to do a program that memorizes the elements formed by a word and a number. For example, if I write ABB 3, AB 2, ABB -2, ABC 5, ZZ 2 the program will write:
ABB 1 (the result of abb (3-2)) ABC 5 AB 2 ZZ 2
Also, should write:
2 AB ZZ 5 ABC 1 ABB
I've tried to do it with a TreeMap but i don't know how it works.