Translate User Inputted Sentence Into MorseCode - No Output?
Feb 19, 2014
The purpose of this program is to translate a user inputed sentence into morseCode. It seems like everything is right to me, but I'm simply not getting output! What am I doing wrong, or what should I add/change?
Here is the main class:
public class MorseCode
{
public static String myInput;
public static String[] myMorse;
public static String myUserInput;
public static char[] myAlph = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
public MorseCode()
[Code] ....
View Replies
ADVERTISEMENT
May 1, 2014
I am trying to write a simple program that checks if a user's input has a specific letter using the ".contains" method but its not doing what i wanted to do. here is my code below.
import java.util.Scanner;
public class secret
{
public static void main(String args[]) {
Scanner sc;
char hidden='a';
String guess;
[Code] ....
View Replies
View Related
May 21, 2014
Ok, so I have to make a program that tells the user to type a sentence and at the end of the sentence a "." must be put to end the program. If a "." period is not entered, it must re-prompt the user to enter a period. On top of all this, the program has to count the number of letters in the sentence. I cant seem to get the while loop working and I cant find anywhere how to make a counter count the number of letters.
import java.io.*;
class Sentence
//The purpose of this program is to
[Code]....
View Replies
View Related
Nov 12, 2014
I am writing a program that is supposed to take 3 numbers inputted by the user and sorting them out in an ascending order. I believe my code is correct but can't figure out why the program isn't behaving as expected.
import java.util.*; //Required to use the scanner console
public class Week3_Programming_Problem
{
static Scanner console = new Scanner(System.in); //Allows for user input
public static void main(String[] args)
[code]....
View Replies
View Related
Mar 6, 2014
I've been working on this problem for a while now and continue to get an error when I try to subtract one user inputted integer from another. It seems to compile fine for adding, dividing, and multiplying. Why it might be making that error and how to resolve it? (As an aside, I have no idea if I did the whole program right but am just trying to figure out why a declared int would come back with an error it's a string.)
import java.util.Scanner;
public class Calculate2
{
public static void main(String[] args)
{
int firstInt;
int secondInt;
int choice;
[Code] ....
View Replies
View Related
Oct 28, 2014
My assignment is to write a program that will encrypt and decrypt a sentence entered by a user but the encryption is to be random using an array. Can I convert my sentence(string) from char to int then create a random array to encrypt?
import java.util.Scanner;
import java.util.Random;
/*SentenceEncryptionProgram
*/
public class SentenceEncryption {
string sentence; //sentence entered by user
[Code] ....
View Replies
View Related
Apr 10, 2014
I've been given an assignment for my Programming Fundamentals class that requires the user to enter a word/sentence to encrypt or decipher, as well as requiring the user to enter a key in which to encrpyt/decrypt the input by.
So a = no shift, b = a shift by 1 and so on.
But I'm completely lost as to what to do, and after searching for Vigenere Cipher topics, they look completely different to mine and (hardly) include prompts?This is my code:
/**
* @(#)VigenereCipher.java
*/
import java.util.Scanner;
public class VigenereCipher
{
public VigenereCipher()
[code]....
View Replies
View Related
Sep 25, 2014
In my account driver I am trying to get the user inputted account number to get the account by account number. In my code
System.out.println("Which Account number: "); int account = scan.nextInt();
ac.get(account-1);
This works if my accounts are numbered incrementally starting with one, I want it to match the inputted account number
System.out.println("Account number: "); int num = scan.nextInt();
I am thinking a for loop is probably needed. Here is my code:
public class AccountDriver {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ArrayList<Account> ac = new ArrayList<>();
boolean more=true;
boolean again=false;
[code]....
View Replies
View Related
May 5, 2014
trying to write a program that takes a user inputted number and converts it to a binary number.
Here's what I have:
package com.java2novice.algos;
import java.util.Scanner;
public class Converter {
static Scanner console = new Scanner(System.in);
public void printBinaryFormat(int number){
int binary = console.nextInt();
[Code]...
Bugs on:
Line 13
Line 17
Line 23
View Replies
View Related
May 25, 2014
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayFinal_Panel extends JPanel {
private JLabel label1, label2, label3;
private JTextField box;
[code]....
I only want Listener 1 to work right now. Also, user input is in TextField.
View Replies
View Related
May 25, 2014
translate this part to jstl and el?
<%
while(i<nrows){
if(i==0){
%>
<tr>
<td ><b>id_article</b></td>
<td ><b><font color="#FF0033">nbr_stock</font></b></td>
<td ><b>critical_nbr</b></td>
<td ><b><font color="#FF0033">date_first_stock</font></b></td>
[code]....
View Replies
View Related
Mar 29, 2014
I want to use google translate api to translate language from one language to another...
View Replies
View Related
Jul 22, 2014
import java.util.Scanner;
//Calculates the prime #1000.
public class Prime {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n, i=2, x=2;
[Code]....
View Replies
View Related
Jul 17, 2014
I need to receive input from the user, as many times as he wants. tha is done with the while loop. I also need to output the min and the max numbers the user enters, therefore i have the if statememnts. also if the user enters only one value i need to output that one value as the min and the max.
int min =0;
int max = 0;
int option = JOptionPane.YES_OPTION;
while ( option == JOptionPane.YES_OPTION){
String dataString = JOptionPane.showInputDialog("Enter an integer");
int data = Integer.parseInt(dataString);
[Code] ....
View Replies
View Related
Sep 20, 2014
I'm using one method to take input from the user and append some text to it, then I am trying to return the value of the variable and use another method to print it out. But for some reason whenever I try doing this I can't print out anything and I only get a "null" output. Why this is happening?
package Homework3;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Homework3 {
[Code] .....
View Replies
View Related
Jul 24, 2014
I'm currently working on a program that is supposed to translate morse code and then display the result and I'm stuck, my program has tons of errors when I try to compile.
public class Assignment10
{
public static void main ( String [] args )
{
String str = Input.getString("Please type in a word");
char [] letters = {'a','b','c','d','e','f','g',
[Code] .....
View Replies
View Related
Jun 2, 2014
I've done a lot of hardwork for this assignment but I don't know what's why the second textfield which is for output is blank.
All I want is to get the input from user in textfield a and display it in textfield b in lower case.
public void KeyPressed (KeyEvent ke) {
String letter2="";
if(ke.getKeyCode()==KeyEvent.VK_A)
{
letter2=letter2+"a";
btextfield.setText(letter2);
[Code] .....
View Replies
View Related
Nov 7, 2014
Using JOptionPane,ask for 10 numbers from the user.Use an array to store the values of these 10 numbers.Output on the screen the number with the greatest value.
View Replies
View Related
Feb 16, 2015
I created my own class and it basically randomizes the amount of 'spells' [magic] a user uses (range 1-5). I can't figure out how to increment the initial randomized output to make something like this :
User X : uses 2 spell.
User Y : uses 3 spells.
User X : uses 3 spells. (Taking the randomized 2 and increment by 1)
User Y : uses 4 spells. (Taking the randomized 3 and increment by 1)
My current setup looks like this : First one is the class I created and the second one is just how the output would look like. (seperate by +++++...)
My goal is to create a METHOD to increment it.
public class Spell {
// Max number of spells
private final int MAX_FACE_VALUE = 5;
// Current face value
private int faceValue;
// New instance of Spell
public Spell() {
faceValue = 1;
[Code] ....
+++++++++++++++++++++++++++++++++
public class SpellOutput {
public static void main(String[] args) {
//Object creation
Spell spellCasterOne = new Spell();
Spell spellCasterTwo = new Spell();
Spell spellCasterThree = new Spell();
[code] ....
View Replies
View Related
Nov 4, 2014
I had to make a program that allows the user to enter 3 sides and it should output "invalid" if it does not make a triangle and if it does make a triangle it calculates the area of the triangle and it doesnt seem to do anything but say "invalid" as the out put.
import java.util.Scanner;
public class MyTriangle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean valid = true;
double side1, side2, side3, area, A;
[Code] ....
View Replies
View Related
May 14, 2014
How do I make it so that if both numbers are entered between 10 and 20 it will print false?
The assignment: Ask the user to enter 2 ints. Output "true" if one of them is in the range 10 - 20 inclusive, but not both. Otherwise output "false"
12 99 → true
21 20 → true
8 99 → false
15 17 → false
import java.util.Scanner;
public class Practice {
public static void main(String[] args) {
//get user input
Scanner user_input = new Scanner(System.in);
System.out.print("Enter a number: " );
[Code] ....
View Replies
View Related
Jun 7, 2015
Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits.
Now I have a code for spacing out the integers, and I have a separate code for adding the digits. But I am not sure how to merge them together. Both of them work independently
Spacing code:
import java.util.*;
public class SumoftheIntegers
{
static Scanner console=new Scanner(System.in);
public static void main(String []args) {
int num1, test, rem;
int counter = 0;
[Code]...
Now the sum of the integers code:
import java.util.Scanner;
public class sum
{
public static void main(String[] args)
{
// Create a Scanner
Scanner input = new Scanner(System.in);
// Enter amount
System.out.print("Enter an integer: ");
int integer = input.nextInt();
[Code]...
View Replies
View Related
Apr 8, 2015
I create a shape then, them translate shape to another place, how I teste if a point is inside the shape?
Rectangle rect = new Rectangle(20, 20, 100, 100);
rect.contains(21, 21); // returns true
rect.setTranslateX(200);
rect.setTranslateY(200);
rect.contains(21, 21); // returns true!!!
rect.contains(201, 201); // returns false
View Replies
View Related
Feb 8, 2014
I have a project requiring me to build a program having a user input 3 words, sort them alphabetically and output the middle word. I have done some searching and seem to only come back with results for sorting 2 words. I so far have code to get the user input but I am completely lost as to how to sort them alphabetically.
import java.util.Scanner; //The Scanner is in the java.util package.
public class MiddleString {
public static void main(String [] args){
Scanner input = new Scanner(System.in); //Create a Scanner object.
String str1, str2, str3;
System.out.println("Please enter three word words : "); //Prompt user to enter the three words
[Code]...
we havnt done arrays yet and I THINK i have to do compareTo.....how to use it?
View Replies
View Related
Jan 5, 2014
Following is the code for my assignment where a user inputs his full name in a string from keyboard. It should be done using BufferedReader. The program will give his initials as output.
############################
For example: User inputs-> Ram Kumar Das
Program Returns-> R.K.D.
I am written the following piece of code. It does not return the correct output. If "Ram Kumar Das" is given as input, it gives R.K.K. as output. Arrays and objects are strictly not allowed.
Java Code:
import java.io.*;
public class Assignment
{
static int i=0;
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main (String args[]) throws IOException
[Code] ....
View Replies
View Related
Apr 5, 2015
I am making a java program that translates English into Pirate. I need working with the Word Pair class. I'm not sure what needs to be passed to the default constructor. And how to do the method that will take the words and pair them. here is my code and the dictionary file
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class PirateTranslator {
public static void main(String[] args)
[Code] .....
View Replies
View Related