Requiring User To Enter Word / Sentence To Encrypt Or Decipher

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


ADVERTISEMENT

Encrypt / Decrypt User Sentence Using Array And Random Encryption

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

Deleting Word From Sentence

Feb 7, 2015

How to delete word "kumar" from sentence

import java.util.*;
class kumar
{
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
System.out.println("Enter a sentence");
String s=in.nextLine();
s=s=" ";

[Code] ....

I do not get any output nor any error....

View Replies View Related

Write A Program To Reverse Each Word In Line (sentence)

Jul 3, 2014

Write a program to reverse each word in line(sentence)?

View Replies View Related

Check If A Sentence From User Has Specific Letter?

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

Make Program That Tells User To Type Sentence?

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

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 View Related

Array List Requiring Variable Not A Value?

Dec 11, 2014

The IDE says an error of "required variable, found value". I thought you need a index value to get a item in the arraylist.

package SuperHero;
import java.util.ArrayList;
public class Driver
{
public static void main ( String args[]) {
//intallizing the supers

[Code] ....

View Replies View Related

How User Enter Data Into JGrasp Without Using GUI

Oct 7, 2014

I'm currently taking a Java Programming module in college, the program we are using is jGrasp and I'm currently stuck on one aspect of the language.

I did VB last year and I enjoyed it and got good grades so I'm comfortable with Java in terms of compiling the code correctly and getting it to run with no errors.

But for a project we got yesterday, the user must be able to enter data (e.g. an answer) into jGrasp without using a GUI. This is the case because we won't be dealing with GUIs until next semester.

I'm able to handle the rest of the project, but the part which I can't figure out is how the user can interact with jGrasp without the aid of a GUI.

View Replies View Related

Prompt User To Enter A String

Feb 15, 2015

I am suppose to design a problem the prompts the user to enter a String. Based on the input from the user, have the program prompt with a full description of the playing card entered. Below is a table of the notation and meaning:

Notation Meaning
A Ace
2...10 Card Values
J Jack
Q Queen
K King
D Diamonds
H Hearts
S Spades
C Clubs

Use the .charAt(...) to extract each character from the user's input and build a switch statement to determine the full description.

import java.util.Scanner;
public class PlayingCardIdentifier {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a card notation: ");
String s = input.nextLine();

[code]...

View Replies View Related

User Enter Empty Line

Oct 5, 2014

I am learning Java on my own, and I am creating little programs to do so.The program below asks the user to input text and hit enter. When user does that, it asks if that is correct. If the user enters "y," the program ends. That's good.If the users enters "n," the strGrategul is set to empty which triggers the while statement to start over again. That's good. However, when the program asks the user to "Tell me one thing you are grateful for..." it doesn't wait for user input. Instead it skips to "You said ''? Enter 'y' or 'n'" It thinks the user enter an empty line.

public static void main(String[] args) {
String strGrateful = "";
String strGoal = "";
String strContinue = "";
Scanner scn = new Scanner(System.in);

[code]....

View Replies View Related

User Option - Enter Either Int Or Double

Apr 21, 2014

I'm trying to write a program where the user has the option to enter either an int or double but whatever input I enter just gets cast to a double. Do I even have the right Idea by using if else statements?

import java.util.*;
public class VS
{
public static void main(String[] args) {
Scanner Input = new Scanner(System.in);
System.out.println("Please enter a number");
if (Input.hasNextDouble()) {

[Code] ....

View Replies View Related

Create A Program That Allows User To Enter A Day Using A Number

Oct 13, 2014

so I had to create a program that allows the user to enter a day using a number and then enter a year and after they did that it would create an entire calendar for that year ..so I have that but the only issue is I can not get the numbers to line up neatly.how to do the entire thing in loops, I tried a couple in here..what this would look like as loops instead of switches and cases and if else

import java.util.Scanner;
public class Calendar {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
 
[code]....

View Replies View Related

ProductCatalog That Prompts User To Enter Number Of Products

Feb 11, 2015

Write a program called ProductCatalog that prompts the user to enter the number of products in the product catalog. The program should then prompt the user for the name and the price of each product in the product catalog. Once all of the products have been entered, the program should output the product information (name and price) of the most expensive product in the catalog. Your solution must use a for loop repetition structure and should use the Product class included in labfiles05.zip to keep track of the product with the highest price. Here is sample output:

Enter the number of products: 3
Enter the name of product 1: iPod
Enter the price of product 1: 158.99Enter the name of product 2: iPad
Enter the price of product 2: 518.99
Enter the name of product 3: iPadMini
Enter the price of product 3: 304.49
Most Expensive: Product [name=iPad, price=518.99]

Your solution should not use an array to keep track of all the product information entered.

I am having trouble with my code, with the For loop and then calling the methods from the Product class into the ProductCatalog. How should I approach this program.

Here is the Product program.

public class Product
{
private String name;
private double price;
public Product(String theName, double thePrice) {
name = theName;
price = thePrice;

[Code]...

Here is the ProductCatalog class where I call the methods from Product class. The For loop is what I am having trouble with as well.
 
import java.util.Scanner;
public class ProductCatalog
{
public static void main(String[] args) {
double number;
String product = " ";
double productCount = 0;

[Code]...

View Replies View Related

Prompt User To Enter Integer From 1 To 15 And Displays A Pyramid

Jun 1, 2014

The exercise sounds like this : Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid , as shown in the following sample run (my code displays correctly the first 9 lines):

1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
7 6 5 4 3 2 1 2 3 4 5 6 7

The problem is when i input a number greater then 9 as it requires 2 spaces . I m pritty sure i solved it incorrectly or at lost not optimal as i m using a string that decreases on each line to create the pyramid effect.

import java.util.*;
public class C5_17 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of lines: ");

[Code] ....

View Replies View Related

Getting User To Enter Integer (registration Number) Between 500 And 5000?

Jan 6, 2014

I am trying to get a user to enter an integer (registration number) between 500 and 5000. if it is below 500 and over 5000 the user should get a prompt "invalid number" and "non-numeric character". See my code below. it is not working when i enter invalid numbers.

import java.util.*;
public class Infomation{
public static void main(String args []) {
Scanner in = new Scanner(System.in);
System.out.print("Student Number:");
int sn=in.nextInt();

[Code] ....

View Replies View Related

Application That Prompts User To Enter Personal Details

Feb 18, 2014

Create a Java application that prompts the user to enter their personal details: First name, last name, gender, address, suburb, postcode, and phone number. Then the program displays all of your personal details to the screen as illustrated. Name the file PersonDetails.jav

package exe
import java.util.*;
public class Review2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your full name: ");
String name = scanner.next();

[Code]...

If you cant tell straight away how i have stuffed up, what is happening is this;

When i am promoted to enter my name, 'John Smith'. The word 'John' would be stored in the name variable, while 'Smith' is stored under gender, so the next prompt is then 'Whats your address?'

So its only assigning one word per variable, now as far i understand, a string should not work that way. So where is my mistake?

View Replies View Related

Prompt A User To Enter Three Tasks And Their Priorities In A Driver

Oct 31, 2014

My full instructions are to Design a Java interface called Priority that includes two methods and two constants. The methods are setPriority and getPriority. The constants are MIN_PRIORITY with value 1 and MAX_PRIORITY with value 6. The interface should define a way to establish numeric priority among a set of objects. Design and implement a class called Task that represents a task (such as on a to-do list) that implements the Priority interface. Assume that Task has two attributes (instance data): name and priority. Define the Task constructor to accept and initialize the name of the task. Each newly created Task should have priority equal to MIN_PRIORITY (the constructor should initialize priority to MIN_PRIORITY). Priorities can be changed using setPriority method. Create a driver class TaskDriver that should do the following: prompt the user to enter three tasks and their priorities, and then print the tasks in the order of decreasing priorities. If the user enters an invalid priority that is less than MIN_PRIORITY or greater than MAX_PRIORITY, then the user should be asked to enter priority again until a valid priority value is entered.

So far I have:

public interface Priority
{
public void setPriority(int level);
public int getPriority();

[Code].....

View Replies View Related

Prompt User To Enter Value Of Their Savings For N Number Of Weeks

Oct 19, 2014

So I have this program where i have to prompt user to enter a the value of their savings for n number of weeks (quarters dimes nickels pennies) and the program outputs the total of savings an average of saving per week and an estimation of saving per year.

I managed to do the first step but the problem is that when they enter the value of their savings i don't know how to save the value of each(quarters dimes nickels and pennies) to make the calculations? Here is what i have so far

import java.util.Scanner;
 public class yearlySavings
{
 public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int numberOfWeeks = 0; // initialize value of numberOfWeeks
 
[Code] .....

View Replies View Related

Allow User To Enter Values For Array Of Seven Salesperson Objects

May 6, 2014

Create an application that allows a user to enter values for an array of seven Salesperson objects. Offer the user the choice of displaying the objects in order by either ID number or sales value.

import java.util.*;
public class SalesPersonSort
{
public static void main(String args[]) {
int[] id = new int[7];
int[] salesValue = new int[7];
final int END = 999;

[Code] ....

View Replies View Related

Write A Program Which Prompts User To Enter 4 Grades Between 0 And 100

Sep 2, 2014

I'm using Jgrasp and my prompt is asking me to write a program where the program prompts the user to enter 4 grades between 0 and 100. And you have to display the grades, and the program has to calculate the minimum grade, the maximum grade and the average.I'm just having problems with the max?

// Import Java Scanner.
import java.util.Scanner;
// Name Class.
public class Practice_4_1

[code]...

View Replies View Related

Allowing A User To Enter X Number Of People Into Array

Feb 5, 2014

I am starting a program that is dealing with arrays. My issue, allowing a user to enter 'x' number of people into an array. How do I first allow them to enter the size of an array, and then enter strings (list) into that array. In addition to this, I need to specify the number of boxes of cookies sold by each person and keep a tally of the number of people selling cookies in each category (e.g. 1-10, 11-20...etc). Instead of having a number 100000, I want the user to enter that size, 'x'.

import java.util.Scanner;
public class cookie {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x = 100;
double saleCount[] = new double [x];
String[] girlScout = new String[100000];
 
[code]....

View Replies View Related

How To Make Shapes Move At Same Time When User Enter Up

Oct 1, 2014

How to make shapes move at same time when user enter up it should move up. It works for rectangle but i don't know how to move the others like that. (btw i am new to java). How can i do that?

import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.geom.Ellipse2D;

[Code] .....

View Replies View Related

Program That Allows User To Enter Up To 10 Integer Grades Into Array

Apr 30, 2015

package question.pkg3;
import java.util.Scanner;
public class Question3 {
public static void main(String[] args) {
// TODO code application logic here
Scanner Luka=new Scanner(System.in);
double sum=0;double count=0;
int[] a=new int[10];

[code]....

I'm required to write a program that allows the user to enter up to 10 integer grades into an array. Stop the loop by typing in ‐1. Your main method should call an Average method that returns the average of the grades.I There's something wrong with my program , the count always stays 0 and the sum is always 1 less than the actual sum.Sample input and output :

Enter grade 1: 8
Enter grade 2: 9
Enter grade 3: 10
Enter grade 4: 5
Enter grade 5: 8
Enter grade 6: 9
Enter grade 7: -1
output

Average grade is 8.1666666667On line 13 I had count=count+1 ;

View Replies View Related

Program Will Require User To Enter Needed Values One After Another

Feb 21, 2015

I have to meet certain requirements for this one program, and one of them is as follow: The program will require the user to enter the needed values one after another. If any of the entered values is invalid, then the program will detect that and go into a loop requiring the user to enter a valid value. The program must keep track of the total number of invalid values that the user has entered.

I know how to set a restriction and create a loop to keep asking the same question until it is satisfactory ( in this case I used a while loop) but I am at loss on how I should keep track of the total number of invalid values. I know I can use an increment but how do I set a variable for when the program meets an wrong input from the user.

View Replies View Related

Program That Prompts The User To Enter Loan Amount And Years

Oct 21, 2014

so I had to make a program that prompts the user to enter a loan amount and the years for the loan and I have the conversions and everything my only issue is that when the chart pops up it just looks like a bunch of numbers and its missing the column headers

for example

Interest Rate Monthly Payment Total Payment

import java.util.Scanner; 
public class InterestRate { 
public static void main(String[] args) { 
double monthlypayment = 0; 
double totalpayment = 0; 
Scanner input = new Scanner(System.in);
System.out.println("Enter Loan Amount");

[Code]...

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved