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 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{
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 am trying to find a concise way to write the sort methods for my class. I am supposed to make a program that can sort objects by a number of fields: year, rank, artist and title.
I used an idea from this thread : java - Sorting a collection of objects - Stack Overflow
And I am trying to use the custom comparator for my sort methods. However for some reason, the sortingBy variable fails to recognize any of the enum types.
Whenever I try to set the sortingBy variable equal to one of them, for example:
Java Code:
private Order sortingBy = Year; mh_sh_highlight_all('java');
I get a "Year cannot be resolved to a variable" error.
What I want to be able to do is make it so every time a specific method is called, say, for example sortTitle(), sortingBy will change to Title, then the SongComparator will sort using the case Title.
Is it possible to do this? I can't figure out how to modify SongComparator's object variables that way.
Java Code:
import java.util.Comparator; public class SongComparator implements Comparator<Song> { public enum Order {Year, Rank, Artist, Title} public Order sortingBy;
I need to modify modules used in the book that run a bubble sort, selection sort, and insertion sort on an integer array such that each module keeps a count of the number of swaps it makes.
How do I code for this?
Then we have to design an application that uses 3 identical arrays of at least 20 integers. That calls each module on a different array, and display the number swaps made by each algorithm.
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 have to organize the rows from the lower to the higher number, the problem is, what I have only organizes the first 3 rows even If I insert 3,4,5...or 10 rows.
for (int i = arg[0].length - 1; i >= 0; i--) { for (int j = 0; j < i ; j++) { for (int k = 0; k < i ; k++) { if (arg[k][j] > arg[k][j + 1]) { int temp = arg[k][j];
It prints 0..9 - why? From what I understand ++i is a prefix, therefore by the time the for loop condition is checked, shoudln't i start with 1? So 1..9?
Write a program that continuously asks for an alphabet letter, and stops when a non-alphabet letter is entered. Then output the number of upper case letters, lower case letters, and vowels entered ....
If I have a comboBox full of id's - is it possible that when I choose said id (click it) it will then transfer over into my textField where I can use that as a prefix for my filename ...
(The file can be created just by having a name in the text field it doesn't need to already exists) ...
So my code works perfectly when I input (a+(c-d) and i get ab+cd- for postfix and *+ab-cd for prefix. However when I input a+b+c for infix i receive abc++ postfix and +a+bc prefix when its supposed to be ab+c+ postfix and ++a b c prefix. So my issue is that any infix input with parenthesis, it converts them correctly, however without parenthesis it does not convert correctly.
import java.util.*; public class stack { public static char[] convertToPostfix(char[] infixEx) { Stack<Character> operatorStack = new Stack<Character>(); char[] postfix = new char[infixEx.length]; int index = 0;
So if I wanted to tell the user that the fifth letter they entered is "____" how would I do that.
I am prompting the user to enter a word and then displaying the length of the String. Now I want to display to the user what the fifth letter of the String they entered is.
import java.util.Scanner; public class StringPractice { public static void main(String [] args) { Scanner input = new Scanner(System.in); String word; int lenght;
I'm writing a java program in eclipse of a tic-tac-toe game. I have to create it using JTextField's only I'm having trouble where the JTextField will only accept one letter and will only accept X and O is there any particular way to do this I started off with this piece of code
String text=tf1.getText(); if(text.length()>1) { System.out.println("this is not allowed"); tf1.setText("");
But it doesn't work so is there something I'm missing....
The point of this program is to search for a specific character in a text file. I want the program to find a character in the file "letterCounter.txt".
The purpose of this project is to determine the letter grade of students. The program needs to accept two command line arguments:
The first being the name of a disk file that contains the names of students, and their test scores, separated by commas followed by one or more spaces. Each line in the file will contain scores for one student.
The second argument is the name of an output disk file. The program is supposed to create a new output disk file using that name.
The number of students in the input file is unknown during compile time. The name of input and output files could be anything and only known during run time. Additionally, the average scores, along with the minimum and maximum scores for each test are to be displayed in the console.
Calculation: Final Score = quiz1 * .10 + quiz2 * .10 + quiz3 * .10 + quiz4 * .10 + midi * .20 + midii * .15 + final * .25 Final Score >= 90% then letter grade is A, 80%-89% B, 70%-79% C, 60-69% D, <= 59% F
I need to know how many four letter strings I can generate that begin with the letter "v". Now I had been testing many ways to do this but anm stuck. I can generate a single line up only a certain amount. I need it to continue till it reaches the max number. So since it needs to always start with V i eliminated the need for four and only a 3 letter string.
package javaapplication4; import java.util.Random; public class JavaApplication4 { /** * @param args the command line arguments */ public static void main(String[] args) { Random r = new Random(); int c = r.nextInt(26)+ (byte)'a';