I have made a program, where the user types in a letter M, C or I to identify their major, if the user types m, c or i, my code does not work.
How could I make my program ignore if the letter is upercase or lowercase? My code is posted below. Can I do this in any easier way then adding this type of code for each lowercase letter?:
Java Code:
if (s.charAt(0) == 'm')
System.out.print("Mathematics "); mh_sh_highlight_all('java');
My current code:
import java.util.Scanner;
public class c4e18 {
public static void main(String[]args){
Scanner input = new Scanner(System.in);
System.out.print("Enter two characters: ");
String s = input.nextLine();
if (s.charAt(0) == 'M')
Write a GUI program to convert all lowercase letters in a string to uppercase letters, and vice versa. For example, Alb34eRt will be converted to aLB34ErT.
Write a program that reads in a line of text and then outputs that line of text first in all uppercase letters and then in all lowercase letters.
INPUT and PROMPTS. The program prompts for a line of text as follows: "Enter the text: " and then reads in an entire line of text as a String .
OUTPUT . There are four lines of output . The first line is "The text in all upper case is: ". The second line is the line that was read in, displayed in all uppercase. The third line is "The text in all lower case is: " and the fourth line is the original line that was read in, displayed in all lowercase.
CLASS NAMES. Your program class should be called ShoutAndWhisper.
This is what I have so far:
import java.util.Scanner; public class ShoutAndWhisper { public static void main(String[] args) { Scanner scannerObject = new Scanner (System.in); System.out.println("Enter the text: "); scannerObject.next(); System.out.println("The text in all upper case is: ");
String sql = "SELECT * FROM user WHERE username =? and password =?" ; pst = conn.prepareStatement(sql); pst.setString(1, username.getText()); pst.setString(2, password.getText()); rs = pst.executeQuery(); if(rs.next()){ do somethig; {
I have 2 textfield that take username and password, on the database thete is a user table
id username password name surname
1 test test test test
people put username and password to the textfield like test test and they logon,but when they write username = TESt and password = teST they can logon too,there is no TESt user on the database or teST password, is the textfield making lowercase all text. or pst.setString(1, username.getText()); is this code changing the text?
I'm trying to create a private method called capitalize() which takes String nameModel in any uppercase/lowercase combination and returns it with the first letter uppercased and all other lowercased. E.g. "stePHeN" returns "Stephen" . This is what I've written so far:
I am trying to sort out all lower case letters out of my text file into a new file. I am not very good with char values. My text file that is being read says
I can sort strings in a collection by uppercase and then lowercase though I was wondering if there is any way of doing it in reverse, sorting by lowercase then by uppercase.
I'm trying to loop through a string and depending on the character, add a JLabel to a game. The problem is the character 'L' represents a lantern but is also used in the reply the game gives which is "LOOKREPLY". I've tried to use some code to ignore the LOOKREPLY bit but it's not working. Here's what I've tried.
But the first image on all of the JLabels is always a lantern, which is what L represents. As it's only 1 lantern this leads me to believe that it's ignoring the first 'L' but for some reason it's not ignoring the 'L' at the end of LOOKREPLY.
In c++, I'm aware that you can use the ignore function to ignore numbers after space, but in string how do I ignore a number after space is found for instance, "109 33" how would I ignore 33?
I'm trying to make a program that will count each letter like if I put the word
e-1 h-1 l-2 o-1
The problem I'm running into is that if I put something like How now, brown cow? It should give me something like this
b - 1 c - 1 h - 1 n - 2 o - 4 r - 1 w - 4
but it doesn't instead the whole program crashes because of the punctuation marks and the spacing. Is there a way for me to fix that? All I know is that it has something to do with the alphabet[pos(letter)]++;
import java.util.Scanner;
public class CharCount { static Scanner keyboard = new Scanner(System.in); //this method should allow the user to enter a line of text (that should all be lower case) and then go to the printResults method public static void main(String[] args) { String text, character; int count; char letter; int[] alphabet; System.out.println("Enter a line of text:"); text = keyboard.nextLine().toLowerCase();// any text entered will be lower case alphabet=countLetters(text);
I have several Buttons wrapped into a VBox. I used setOnSwipeUp and setOnSwipeDown for up and downs the buttons. But when there is no more buttons the scroller continues but shows nothing, is empty. How do I do when there are no more buttons ignore swipe gestures?
[Java] // Menu Swipe Up menubox.setOnSwipeUp(new EventHandler<SwipeEvent>() {
I have to create a code that can calculate the number of upper case letters in a string that is entered by the user (below.)
Java Code:
import javax.swing.JOptionPane; public class mainClass { public static void main (String [] args) { String userInput; userInput = JOptionPane.showInputDialog("Enter a string.");
[Code] ....
My issue is that I would like the program to be able to function properly when spaces are entered into the string. As it is right now, I believe it is only processing the first string entered into the input box.
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); } }
I can't figure out why my code doesn't work. My task is to replace for example ä=>ae, using this method String.charAt(int index). So here is my code:
public class pich { public static void main(String[] args) { String text = "Die süße Hündin Leica läuft in die Höhle des fülligen Bären "+ "Iliyan (ein Übergrößenträger), der sie zum Teekränzchen eingeladen hat."+ " An ihrem Öhrchen trägt sie modisch eine Ähre."; String textOhneUmlaute = "";
[Code] ....
when I launch my code I get the same String and nothing has changed
I tried this but it only gives me one letter that corresponds to the number
package pkg2911homework.pkg1; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner keys = new Scanner(System.in);
While using generics, are there cases when ? wildcard cannot be replaced with letters [A-Z]? So far , I was able to find only one case, it is when you want to have field pointing on generic instance without making class generic.
class OneClass { private LinkedList<?> myLL; }
In case above, as I understand, you cannot use [A-Z] without generalize OneClass. Are there any other cases, when there is no way except to use ? wildcard instead of letter [A-Z]?
I have devised a simple program that reads a file and then adds up al the integers in the file and print the result, for example if the file had the numbers 1 2 3 4 5 6 7 8 9 10 then the program would print 55
However i have trouble when non integers are put into the file for example if it was 1 2 3 string 4 5 6 test 7 8 9 10
then i get:
Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at Week7.Task3.filereader(Task3.java:25) at Week7.Task3.main(Task3.java:14)
my code is as follows
package testing;
import java.util.*; import java.io.File; import java.io.IOException; public class summingInts { public static void main(String[] args) throws IOException { Scanner textfile = new Scanner(new File("intSum.txt"));
My professor is a man who enjoys making his students form large, but often simple symbols with smaller letters. That might not have clarified much, so let me demonstrate:
VVVVVVV VVVVV VVV V Or... X X X X X X X X X Or lastly... O O O O O O O O
My problem is, that I've always been bad at figuring out the logic behind these.
I can kinda' see it (somewhat) in my head though... I'd need a double for-loop which depend on the sizes, one that monitors the spaces and one that monitors the symbols, with some conditionals in there. How to make symbols like this, using letters, in Java.
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;