String Manipulation For Program Manipulating Name Of City

Jan 23, 2015

I have to write a program that asks the user to enter the name of their favorite city and use string variable to store the input. The program should display the following:

-The number of characters in the city name
-The name of the city in all uppercase letters
-The name of the city in all lowercase letters
-The first character in the name of the city

However, I can't seem to get past the following errors;

Programming Challenge #12.java:37: error: variable cityFirstChar is already defined in method main(String[])
char cityFirstChar = city.charAt(0);
^
8 errors[CODE
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
[/CODE]

My code is as follows:

import java.util.Scanner;
 
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
 
[code]....

View Replies


ADVERTISEMENT

Manipulating A String

Jul 26, 2014

I have strings in forms like s="(S (NP (DT This)) (VP (VBZ is) (NP (DT an) (JJ easy) (NN sentence))))"Programatically, I need to have words which end with ')' to be in an extra pair of brackets.. such that s = "(S (NP (DT (This))) (VP (VBZ (is)) (NP (DT (an)) (JJ (easy)) (NN (sentence)))))

Note that , words like "this" and "is" are now enclosed in brackets.I tried to create a program which would search for an alphabet followed by ')' and would put it in bracket... but then arrays can't have insertions in between.

View Replies View Related

Program For Airline Ticket Booking - Fixed Origin City And Five Destination Cities

Oct 26, 2014

I am doing a pretty basic program with a fixed origin city and five destination cities. I am having trouble with entering passenger details. This is what I tried, but then I cannot retain all passenger details to print later on in the final ticket.

System.out.println("Enter flight details of child passengers (below 12 years)");
System.out.println("Enter Name");
for(a = 1; a <= cp; ++a)
{
//cp is number of child passengers, a is loop variable
String name = br.readLine();
System.out.println("1. " + name);
}

View Replies View Related

String Manipulation - Getting User ID?

Apr 17, 2014

I have a string and i need to do some manipulation with that. I have tried couple of things but not sure if those are feasible or not. Here is the situation:

uid=aa,bb,ou=people,cn=administrativeldap,cn=punit.punit.a-12-m020.20,o=ttt

I want the value of uid from this string, actually it's user id.

This particular string i want :: aa,bb

Things which i have tried:

I was trying it in this way string start with uid and ends with ou, but in this case user name itself can have ou, so in that case it breaks. Another approach i was thinking of is splitting the string by = which gives me aa'',bb,ou at first position and then i will again split this string to remove ,ou. but i am not sure if this approach is good or not?

View Replies View Related

String Manipulation - Extract Substrings Consisting Of First N-4 And Last Three Characters

Feb 18, 2014

I do have a quick question about string manipulation. You see I've been given a simple exercise that involves asking the user to input a number between 1,000 and 999,999 and displaying the result. Simple enough, but the caveat is that if the user keys in the comma, say 24,000 instead of 24000 for example, the program is not to display the comma. I don't see how to do this without an 'if' statement. The book says the 'if' is not necessary but does offer this hint: "Read the input as a string. Measure the length of the string. Suppose it contains n characters. Then extract the substrings consisting of the first n-4 characters and the last three characters."

What good is n-4 going to do if the string's lengths varies?

Here's what I have written thus far:

import java.util.Scanner;
 public class P13
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Please enter a number between 1,000 and 999,999: ");

[Code] .....

View Replies View Related

Allow User To Input One Or More Integers And Store Them In Vector For Manipulation Later On In Program

Oct 1, 2014

I'm playing with vectors for the first time... What I'm trying to do is to allow a user to input one or more integers and store them in a vector for manipulation later on in the program... Here's the portion of the program I'm working with:

Java Code:

package com.itse2317;
import java.util.*;
public class VectorTest
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);

[code]...

My question is this: Is there any way to move from inputting integers to printing them, without entering a non-integer (for example, hitting enter)? I looked at the API for the Vector class, and either I'm not thinking about the problem the right way to be able to find an answer, or it's just not there.

View Replies View Related

Stored Function - Calculate Delivery Charges Given City And Weight

May 27, 2014

A stored function to calculate delivery charges given city and weight.
 
CREATE OR REPLACE FUNCTION CALCULATE_CHARGES
(
CITY IN VARCHAR2
, CHARGES IN NUMBER
, TOTAL IN NUMBER
) RETURN NUMBER AS
BEGIN
RETURN total:=city*charges;
END CALCULATE_CHARGES;

View Replies View Related

Manipulating Data From Buffered Reader

Nov 3, 2014

I've got a .csv file with some text and numeric data. I've used BufferedReader to successfully print the data to the console. Now I need to perform mathematical operations on the numerical data. How do I access the data from the BufferedReader in my calculation methods?

This is what my BufferedReader looks like:

ReadCVS obj=new ReadCVS();
obj.run();
}
public void run(){
String csvFile = "myDataSet.csv";
BufferedReader buffread=null;
String row="";

[Code] .....

What I would like to be able to do is create some loops to calculate totals for some of the elements, but I'm not sure how to access the data from other methods (and potentially classes?).

View Replies View Related

Manipulating Strings In A File Scanner

Feb 25, 2014

I was given a text file that has list of names phone numbers, calls in and out etc... Like this

Adams#Marilyn#8233331109#0#0#01012014#C
Anderson#John#5025559980#20#15#12152013#M
Baker-Brown#Angelica#9021329944#0#3#02112014#C

The # are delimiters between data items and each line has the call status as the last item. I need to know how I can display each persons information on the screen in a format such as:

Name Phone Calls Out Calls In Last Call

Marilyn Adams (823) 333-1109 0 0 01-01-2104
John Anderson (502) 555-9980 20 15 12-15-2013
Angelica Baker-Brown (859) 254-1109 11 5 02-11-2014

I have to use substring method to extract the phone number and add parentheses/dashes ect I also must have a while statement and a delimiter...

So Far my code looks like this Also I am in a beginners Java coding class....

import java.util.Scanner;
import java.io.*;
 public class phonedata2_1 {
public static void main (String[] args) throws IOException {
  String Phonefile, FirstName, LastName;
Scanner PhoneScan, fileScan;
 
[Code] ....

View Replies View Related

Swing/AWT/SWT :: Double Drawing Pixels When Manipulating DataBuffer Of BufferedImage

Feb 9, 2014

I've been working my way through a tutorial to build a simple 2D tile-based engine that also allows the code to manipulate the colour of pixels on the screen based on a monochrome map read from a file. I've got the code right line for line, but I seem to have a bug when it comes to draw to the screen! At regular intervals, despite what is held in the pixel array of ints (which I have confirmed to be correct when debugging), I get the same row of pixels being draw twice in a row. I figured there was some loop issue somewhere, but after attempting to debug this for some time, I haven't come up with the answer.

Original tilesheet:As rendered:

Game.java:
package igg.engine.game;
import igg.engine.game.gfx.Screen;
import igg.engine.game.gfx.SpriteSheet;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;

[Code] ....

View Replies View Related

Some Pixel Manipulation

Oct 25, 2014

I currently have an on going project of making a gameengine and am currently doing a lighting engine. How to create simple algorithm of explain to me the concepts of creating a algorthm to do a task, like explain how to get the hue saturation and brightness. This preferably needs to be done in java for me to copy the code but as long as i have a concept to go by I could probably translate the code over so it's not to much of a problem.

View Replies View Related

Parallel Manipulation Of XML Files

Sep 15, 2014

I'm currently starting my thesis where my Project will involve creating a diff and merge tool for simulink slx files. These are built using several xml files, a png and sometimes some other data files. One can get to these files by changing the file extension to zip.

I am a bit troubled by this since I want to be able to handle all these files simultaneously and hence need to do this automatically when choosing the slx file.

View Replies View Related

Object Contains Manipulation Code?

Mar 9, 2014

"Object contains data and code to manipulate that data."

Is the statement right ?? as far as i know object only contains copy of instance variables.

View Replies View Related

Another Java Pixel Manipulation

Nov 21, 2014

I have a jpeg that I need to print a border around. My plan was to take the jpeg and throw it on top of a second image that is a few pixels bigger in each direction. Currently, my code prints the image with a white border on the right and bottom sides. Is there a way to print the border on all sides, and maybe even make it a more distinct color? I am not allowed to use graphics. I can only manipulate pixels. Here is the basis of my code.

public class MyArt
{
private Picture image;
/**
* Create an Art object using the jpg or bmp at the indicated location
*/
public MyArt(String filename)
{
image = new Picture(filename);

[code]....

View Replies View Related

How To Create 2D Application For Manipulation Of Image

Apr 14, 2014

I need to create an java 2D application for the manipulation of image. I saw the JAI library but it can not install it properly, I also copied the jar but I can not find the solution. How can I do? there is a replacement for JAI? what other libraries can I use?

View Replies View Related

Pixel Manipulation - Create Art Object Using JPG Or BMP At Indicated Location

Nov 20, 2014

I am working on a project using pictures and am having some trouble. My assignment is to take a jpeg, and reflect it(over an imaginary x-axis so to speak). As this is my first time working with images, I am very lost. My approach was to take "pixel 0" and have it swap places with "pixel max". Theoretically, I believe I would only need to do this for the first 50% of the pixels, as each flip works on 2 opposite pixels. With my code thus far (the reflect() method), I print the left half of the image. Note: I must use pixel manipulation. I cannot use graphics.

public class MyArt
{
private Picture image;

/**
* Create an Art object using the jpg or bmp at the indicated location
*/
public MyArt(String filename)
{
image = new Picture(filename);

[Code] .....

View Replies View Related

Making A Rectangle - Manipulation Of Instance Variables

Sep 11, 2014

I am suppose to create a rectangle and I have created two classes; Rectangle.java and RectangleTester.Java.

So far my code for the class Rentangle.java is:

package edu.sbcc.hw2;
public class Rectangle {
private int width = 25;
private int height = 25;
public rectangle(int xcoord, int ycoord, int thewidth, int theheight) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;

So for my assignment I need two instance variables for height and width for which I have, but it says in the assignment I need methods (settings and getters /mutators and accessors that allow manipulation of my instance variables which is a little confusing. Do I put these methods on Rectangle.java or RectangleTester.java.

The same goes for the calculateArea, where am I suppose to put this?

View Replies View Related

JList Manipulation - How Operating Systems Manage Processes

Sep 29, 2014

I am attempting to use JLists to complete a program that models how operating systems manage processes. A quick synopsis of what it is supposed to do. Each process is to have a priority level (I chose to do 1 -3 with 3 being the most important) and there are supposed to be three lists. One for ready processes, blocked processes, and a running process.

My issues:

1) when I block a process it does indeed switch lists but when it is copied into the blocked list it pulls the element number instead of what the actual process number is. For ex: Say the ready list has 5 processes / I delete 2 / Leaving process 1, 2, 5. When I block 5, it gets registered in the blocked list as process 2.

2) I can't figure out how to give a label to each of my scroll panels (JLists) to signify which box is ready / blocked / and running

3) My switch button - I have commented in what I need to do but don't know how I am going to do it.

Below are my files:

Main

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class PQueue {
public static void main(String[] args) throws InterruptedException {

[Code] ....

View Replies View Related

JavaFX 2.0 :: Manipulating Several Windows (Window Inside Window)

Apr 6, 2015

I am new to javafx I start using it instead of swing i used the scene builder for my forms the problem i faced i don't know how to have main screen with menu bar at top and depending the select from the menu it will open other windows and those window must be inside my window just like for example netbeans.

I don't need to open new window in separate i need all windows inside my main window and controlling over them minimize maximize perhaps.

View Replies View Related

Swing/AWT/SWT :: Image Manipulation - Create Application Where Image Is Displayed On One Label

Apr 7, 2014

Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.

View Replies View Related

String Reverser Program?

Feb 14, 2014

I was tasked to make a program that took a string input, then reversed it using recursion. I'm getting a syntax error causing an exit code 1. Also, I'm sure there may be an error in the code as I'm not very strong with recursion.

import java.util.Scanner;
public class StringReverser
{
public static void main(String[] args)

[Code].....

View Replies View Related

Program Will Only Accept Input From 1 String?

Jan 14, 2015

I am trying to create a fortune teller and everything is running fine except the program does not prompt you to answer the questions

Do you like donuts?
and
What did you have for breakfast?

Here is the code this is in Bluej :

import java.util.Scanner;
public class FortuneTeller {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Welcome to Fortune Teller");

[Code] .....

View Replies View Related

Program Not Recognizing String Sentinel?

Jun 10, 2014

I'm new to Java and am trying to create a simple payroll program that uses a while loop to repeat until the user enters "Stop" for the employee's name. I've tried everything I can think of and everything others have suggested and for some reason, I cannot get the program to differentiate between the word "Stop" or any other word. what I'm doing wrong? My code is as follows:

import java.util.Scanner; // imports scanner class for user input
public class Payrolltest {
public static void main( String[] args )// begins execution of program {
Scanner input = new Scanner( System.in ); // creates a scanner to obtain user input
String Employee = "name"; // employee's name

[code]...

View Replies View Related

Program Is A Random String Generator

Sep 11, 2014

The program is a Random String Generator; it takes user input (type of string, and length), and then generates a string with their requested method. Its extremly simplistic, but had some interesting coding challenges considering I only just did 'Hello World' a few days back xP I actually already have quite a few additions and modifications I want to make to it, but wanted to get a bit of feedback on it otherwise.

The Main Class, RandomStringGenerator.java:URL...
InputHandler.java:URL....
RandomGenerator.java: URL....

View Replies View Related

String To Unicode Converter Program In Java

Mar 2, 2014

I need a program to convert any string of any language to unicode using java....

View Replies View Related

Create A Java Program That Accepts A String

Feb 19, 2014

So basically I have to create a java program that accepts a string and does the following:

1.) Insert a blank space before capital letters
2.) Convert any capital letters into lower case except the first letter(if it is capital).

So if the user enters "HiMyNameIsJohn", the result should be "Hi my name is john". I am having problems inside my changeMe method. Everything works fine including putting a blank space in between upper case words. So from the previous example, my code would show "Hi My Name Is John". I am having issues making the code to convert the upper case letters into lower case. Im pretty sure the code should be right after the str.insert(i, " "). But I do not how to code it. Ive thought about Character.toUpperCase(ch); but doesnt work.

Java Code:

import java.util.*;
public class WordSeparator
{
public static void main(String[] args)
{
String word1, word2;
Scanner userInput = new Scanner(System.in);

[code]....

View Replies View Related







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