Print List Of Jobs That Correspond With Inputted Day

Oct 21, 2014

I'm having some trouble with my project. I have filled the getters using an array and what I now need to do is get the user to type in a day and print the corresponding getters to the lines the day is on in my text file.

{
File file = new File("DailyJobs.txt");
Job newJob = new Job();
try (Scanner scanner = new Scanner(file);)/>
{
while(scanner.hasNextLine()) {
String line = scanner.nextLine();

[Code] ....

This is what I've attempted in terms of entering the day. It recognises the number of lines that has the inputted day but prints out only the very last job ID in the text file.

90301,14304,ITGURU,11/11/2014,Tuesday,735.75,1204,1205
90302,14314,ROK5TR,12/11/2014,Wednesday,335.75,1205
90303,14318,HRTBRK,13/11/2014,Thursday,125.5,1200
90304,14310,EVOH8R,14/11/2014,Friday,1207.95,1211
90305,14300,G4MER,11/11/2014,Tuesday,500,1204,1202

[Code] ....

This is the text file, the first number on each line is the Job ID and always prints the last line regardless of the day I enter.

View Replies


ADVERTISEMENT

Print Inputted Data - Name / Score And Average Using Array

Aug 22, 2014

Conditions : Need to print all the inputted data(name,score) and the average.

import java.util.Scanner;
public class Case2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] score = new int[5];
String[] name = new String[5];
int ave = 0;

[Code] .....

View Replies View Related

Program Does Not Print The List?

Aug 22, 2014

the program does not print the list when i select choice 3 it only prints the original 2 elements, same happens if i use if else statements instead of switch statement. Quote public class linklistdemo{

public static void main(String args[]){
while(true) {
System.out.println("press one enter element");

[Code]....

View Replies View Related

Can't Get GUI Program To Print Out Queue List

Apr 11, 2014

I have been working on this Java Gui program and i cant get it to print to the textbox correctly.i originally had it displayed in a dialog window but it would print one integer a time in a seperate window.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
import java.io.*;

[code]....

View Replies View Related

Sort Array List Print?

Nov 23, 2014

I am having an issue trying to print different types of arrays using one method. Eclipse tells me to convert my print method for each array type:

change method 'printList <e>' to 'printList(ArrayList<integer>)'
change method 'printList <e>' to 'printList(ArrayList<Double>)'
change method 'printList <e>' to 'printList(ArrayList<Character>)'
change method 'printList <e>' to 'printList(ArrayList<String>)'

I would like to accomplish printing all four different arrays using one print method. How to accomplish it or provide examples or links to examples?

import java.util.ArrayList;
public class SortArrayList {
public static class Sort {

[Code].....

View Replies View Related

Traverse Linked List From First To Last Node And Print Data Value

Jan 1, 2015

AddItemToFront(Item p) : This method will create a new Node with the Item object as its data value and then add the newly created node to the front of the linked list.

DisplayItems(): This method will traverse the linked list from first node to last node and print data value ( i.e., id, name, type and price of the Item object) of each node.

RemoveItemAtPosition(int n): This method will remove the node at position n in the linked list. Assume that the first node of the linked list has a position number of 1 and the second node has a position number of 2 and so on.

This is my Code

AddItemToFront
public void AddItemtoFront(Item p)
{
Node newNode = new Node(p);
newNode.setLink(head);
head = newNode;

[Code] ....

I don't know what am I suppose to do inside the remove method

View Replies View Related

Reading From Text File - Print Linked List On Console

Mar 9, 2015

How can i convert this linked list code to a read from input.txt

The first line in the input file will give the elements to initialize the linked list with. Consecutive lines will provide operation instructions.

Your code should read one line at a time. After reading each line, it should perform the corresponding operation and print the linked-list on the console.

If an operation is not possible, it should print "N/A".

Sample input file. Please note, the comments (// ...) are given for explanation, the input file will not have them:

4, 5, 6, 3// First line. This will provide the initial values for the linked list : 4->5->6->3
1, 9// Add a 9 at the front of the linked-list. After this operation the linked-list should be: 9->4->5->6->3
2, 1// Add a 1 at the end of the linked-list. After this operation the linked-list should be: 9->4->5->6->3->1
3, // Delete the first node in the linked-list. After this operation the linked-list should be: 4->5->6->3->1
4, // Delete the last node in the linked-list. After this operation the linked-list should be: 4->5->6->3
5, 11// Delete the node with the value 11 in it. Since this is not possible, it should print "N/A"
5, 6// Delete the node with the value 6 in it. After this operation the linked-list should be: 4->5->3

Sample output to the console:

4->5->6->3
9->4->5->6->3
9->4->5->6->3->1
4->5->6->3->1
4->5->6->3
N/A
4->5->3

My Code:

LinkedList.Java

class linkedList
{
protected Node start;
protected Node end ;
public int size ;
 
[Code] .....

View Replies View Related

Method That Print Data Of Single Linked List Backward Using Stack

Apr 23, 2015

I am trying out solving the question but i am stuck.The problem is to write a method that print data of single linked list backward using stack.The question is as follow

public class Stack{
public boolean isEmpty(){};
public void push(int n){};
public int peek(){};
public int pop(){};
}

public class node{
int data;
node next;
}

public class list{
node first;
}

View Replies View Related

Getting Strings To Print In A List So That User Can Select Object To Manipulate Its Attributes

Oct 6, 2014

I have an Array of objects that contains strings. I am new to Java and have read books, the Java docs, and searched the Internet for my problem to no avail. How can I get my strings to print in a list so that the user can select an object to manipulate its attributes? I have a class called Instruments and created 10 guitar objects. Here is the code:

Instrument [] guitar = new Instrument[10];
for (int i = 0; i < 10; i++) {
guitar[0] = new Instrument("Guitar 1");
guitar[1] = new Instrument("Guitar 2");
guitar[2] = new Instrument("Guitar 3");
guitar[3] = new Instrument("Guitar 4");

[Code] ....

View Replies View Related

Invoke Some Methods In For Loop In Order To Print Some Info Stored In A List

Apr 28, 2014

I am trying to invoke some methods in a for loop in order to print some info stored in a List. But for some reason, compiler pops a message saying "cannot find symbol - method getEmpID(). You are using a symbol here (a name for a variable, method or class) that has not been declared in any visible scope." But I am pretty sure that method getEmpID (as also getName(), getAfm(), and payment() ) have been declared as public.

Note: My List contains objects of different type (SalariedEmployee, HourlyEmployee). I hope this is not the factor causing this problem.

Java Code:

import java.util.*;
abstract class Employee{
private String name = "";
private String afm = "";
private long EmpID;
static long count=0;

[code]....

View Replies View Related

Get Object Strings To Print In List So That User Can Select That Object To Manipulate Its Attributes

Oct 7, 2014

I am new to Java and have read books, the Java docs, and searched the Internet for my problem to no avail. I have an Array of objects that contains strings. How can I get the object's strings to print in a list so that the user can select that object to manipulate its attributes? For example, the user can select "Guitar 1" from a list and manipulate its attributes like tuning it, playing it, etc. I have a class called Instruments and created 10 guitar objects.Here is the code:

Instrument [] guitar = new Instrument[10];
for (int i = 0; i < 10; i++) {
guitar[0] = new Instrument("Guitar 1");
guitar[1] = new Instrument("Guitar 2");
guitar[2] = new Instrument("Guitar 3");
guitar[3] = new Instrument("Guitar 4");
guitar[4] = new Instrument("Guitar 5");
guitar[5] = new Instrument("Guitar 6");

[code]...

View Replies View Related

Print 2 Lists - 20 Random Numbers And Another List Without Duplicate Numbers

Feb 1, 2015

I'm trying to make a program that generates 20 random integers between 1 and 20 and then prints the list of random numbers to the screen. After that, I want to print a different list to screen with the same numbers from the first list only skipping any number that has been already printed to the screen. So two lists are printed to the screen. The first one has 20 random numbers. The second one has those same 20 numbers but only prints the numbers in the first list that aren't duplicated. So if m

y list of 20 random integers contains three 2s and two 14s, only one 14 and one 2 is printed to the second list. Currently, my code generates 20 numbers from 1 to 20 and stores those numbers in an array but I don't know how to print solve the second part of my problem. I don't know how to print the s different list only without duplicate numbers. As a result, my output is nothing because it doesn't print any number from the first list as oppose to skipping only duplicate one.

public void randomNum(){
System.out.println("Twenty random integers: ");
int max = 20; // max value for range
int min = 1; // min value for range
Random rand = new Random();
int[] all = new int[20];

[Code] ....

View Replies View Related

Why Program Does Not Display Anything When Choices Are Inputted

Feb 28, 2014

I am experimenting with messages in JOptionPane and I was wondering why this program does not display anything when the choices are inputted.

*note: I tried putting "JOptionPane.showMessageDialog(null, "This is an information message", "Information", JOptionPane.INFORMATION_MESSAGE);" after the "int i = 0;" and then the messages displayed.

Scanner scan = new Scanner(System.in);
int i = 0;
while (i != 6)
{
System.out.println("1. Information message");
System.out.println("2. Error message");
System.out.println("3. Question message");
System.out.println("4. Plain message");
System.out.println("5. Warning message");

[code]....

View Replies View Related

Find Average Of Integers That Are Inputted

Jul 26, 2014

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

[code]...

find the average of the integers that are input but can't manage to solve the problem.

View Replies View Related

Nested For Loops - Determine If Inputted Integer Is Even Or Odd

Sep 29, 2014

So I cant figure out why my output for my for loop isn't working properly. So the output for the square comes out right but the for loop isn't working properly for the H. I have tried to figure it out and it should go to the next line but its not.

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

[Code] ....

Output

Enter a positive odd integer: 5

Square:
*****
* *
* *
* *
*****

H:
* *

View Replies View Related

Constructors - How To Put 3 Values Of Each Variable Without Replacing Last Inputted One

Oct 2, 2014

Java Code:

public class Puppy{
int puppyAge;
public Puppy(String name){
// This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public void setAge( int age ){
puppyAge = age;

[Code] ....

How do I put 3 values of the each variable without replacing the last inputted one?

Like when I input "Tommy" and input another name "Gerald", "Tommy" won't be replaced by "Gerald" when I input again.

View Replies View Related

Change A String Using Specialized Codes That Are Inputted

Feb 10, 2015

In this code, I have to do a series of tasks to change a String using specialized codes that are inputted. The one that I am having trouble with is as follows:

MC-SLXD: Circulates the sub-string in position S with a length of L, rotate the string X characters over in the direction of D. All the arguments (S,L,X and D will be one character in length. The direction will be either L or R for Left or Right.Example: MC-332R/COMPUTER = COPUMTER.

View Replies View Related

Counter Set Up For 20 People But Only Counts 19 If Error Inputted In GenreType

Oct 15, 2014

This is a piece of a program I am trying to write,my only problem is when an incorrect input is entered in "genreType" it still counts as a loop and therefore I do not end up with 20 results I am looking for..I have tried multiple different ways but nothing seems to work for me.

package assignment_1;
import javax.swing.*;
public class Assignment_1 { 
public static void main(String[] args) {
int rockCounter=0;
int popCounter= 0;
int danceCounter= 0

[Code] ....

View Replies View Related

How To Make A Program That Determines The Highest Value Out Of Inputted Numbers

Sep 14, 2014

how to make a program that determines the highest value out of the inputted numbers.

View Replies View Related

Change Specific Lines In Text Inputted From A File

Nov 29, 2014

I can't seem to understand how to change certain line of text, inputted from a file. For this I really don't know where to begin. I have got the input from the file. But I want to change like very other line in the file. Can't seem to understand how this could be done. Is there away to access specific lines from the file and edit them? So far, i have this:

import java.util.*;
import java.io.*;
public class ChangeEveryOtherLine {
public static void main(String[] args){
//Constructing file object representing input file
File inputFile = new File("input.txt");

[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

Numbers Inputted By User And Sorting Them Out In Ascending Order

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

Code Which Catches Exception When Mismatch Variable Inputted

Feb 27, 2015

I am trying my code which catches exception when mismatch variable is inputed as i read it with Scanner. It seems right for me but whenever i run it, it keeps leaking memory or something like that

Code :

import java.util.*;
public class Exercise10_1 {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
boolean exception;
do

[Code] .....

View Replies View Related

Subtract One User Inputted Integer From Another - Bad Operand Types

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

How To Get Index Of Array Based On User Inputted Account Number

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

Comparing Inputted Guess To Computer Random Sequence - Counter Not Working?

May 27, 2014

I have separated characters into an array that can be accessed from any method, however, when I try to compare the inputed guess to the computers random sequence, the counter always comes back as 0 (the comparison occurs in the checkColour method).

Java Code:

package mastermind;
import java.util.Scanner;
/**
* Program Description: play a game of mastermind versus the computer
*/
public class Mastermind {
private static int block1, block2, block3;
private static String blockColour1, blockColour2, blockColour3;

[Code] ....

The counter is called colourCorrect.. But I think the problem lies more in me converting the strings (input and computerGuess) into char arrays, as if I output the values at position in the array, I get numbers (but the numbers are not character values from the ascii table).

View Replies View Related







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