Boolean Method - Adding Information To Mailing List Based On User Input

May 5, 2014

This program contains a superclass and a subclass that will gather the following information from the user:

name, address, phone number, and customer number.

Everything works fine except that I have to create a boolean method in this program that is required to determine based on user input whether they want to be added to a mailing list.

I cannot get this method to work with main, each time it is called it will always return the value but main will constantly read the last statement (else, where it will read "not wanting to be added to the mailing list).

The only way I can get this part of the program to work is by adding an equals method in main that ignores the case, but I am required to write a boolean method so this is not allowed.

Superclass:

public class Person
{
private String name;
private String address;
private String phoneNum;
public Person(String pName, String add, String number)
{
name = pName;
address = add;

[Code] ...

View Replies


ADVERTISEMENT

Adding User Input To File - Information Overwritten?

Dec 8, 2014

I need to write a program that will let a user input name, age, email, and cell phone number, and commit the input to a text file. They need to add multiple entries. I figured out how to create the file and write to it, but when the user enters a second set of information, the first is overwritten. How can I make the file be added to instead of overwritten? The following is my code:

try
{
FileWriter writer = new FileWriter("ContactInformation.txt");
BufferedWriter bw = new BufferedWriter(writer);
nameTextField.write(bw);
bw.newLine();

[Code] ....

View Replies View Related

Changing Boolean Method Based On Result

Sep 20, 2014

I am working on a program that simulates someone logging in. For this program, I have three methods:

public void input(String text)
public void click(String button)
public boolean loggedIn()

Naturally, the default status of loggedIn() is false, but I am having trouble changing the boolean to true when a user has successfully entered a username and password.

Specifically,

public void click(String button) {
Button = button;//Button is declared at the beginning of the class
if(Button == "Submit") {
//Statement that changes loggedIn() from false to true when the user clicks the "Submit" button.
}

No matter what I try, I get various errors about how what I tried was illegal.

View Replies View Related

JavaFX 2.0 :: Adding Tooltip On Cell Of TableView In Order To Show Some Information To User

May 21, 2014

I'm trying to add a tooltip on a cell of a TableView in order to show some information to the user.
 
This is the code:

colonnaColore.setCellFactory(param -> {
            TableCell<Appuntamento, Template> cell = new TableCell<Appuntamento, Template>() {
                @Override
                protected void updateItem(Template item, boolean empty) {
                    // calling super here is very important - don't

[Code] ....
 
In few words: there is a cell factory on the cell to show a colored box, then I added a tooltip to the cell. I need informations that are in the item added to the TableView that has type "Appuntamento". So I try to get my element with these code (that in others part of my code works); but here I get a Null Pointer Exception on cell.getTableView() and also on cell.getTableRow().
 
I'm probably using these methods in a way that was not expected.

View Replies View Related

Create A Program That Keeps Track Of Information Input By User

Sep 17, 2014

I am new to Java an have to Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, and Age. Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns.You should be able to add and remove contacts in the array.

View Replies View Related

Arrays With User Input - Sorting Information Correctly?

Oct 12, 2014

I am new to using arrays. I need to collect user input for book title, author, and # of pages... store that in an array... and then I'm going to need to be able to sort that array. The dialog boxes come up prompting the user for 5 sets of title, author, and # of pages, but when I try to display that information, it isn't working. I am assuming this means that it's not storing the information correctly... so I want to get this corrected before I even try to sort??

import javax.swing.*;
import java.util.*;
class LibraryBookSort
{
public static void main(String[] args)
{
LibraryBook[] someBooks = new LibraryBook[5];

[Code] ....

View Replies View Related

Edit User Information By Bringing In Input Fields From Database Using JSP

Jul 11, 2014

I can insert data in database, delete aslo using JSP. But facing problem while updating the information saved in database as m using MySQL 2008. I want to see the bring saved in database with particular username into the updateinfo.jsp form.

View Replies View Related

Variable Fields Are Not Holding Information Through Constructor From User Input?

Oct 19, 2014

Variable Fields are not holding information through constructor from user input so here's what I did instead.

View Replies View Related

User Input Student Information - Print Out Name With Grade In Descending Order

Nov 23, 2014

I had to make a program that allowed the user to enter the number of students and the students names and grades and then print out the name with the grade in descending order. right now I only have it where it prints the names out in descending order. how do I get it the print out with the grade?

Here is my code

import java.util.*; 
public class Grades {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of students: ");
int numofstudents = input.nextInt();

[Code] .....

View Replies View Related

Retrieving Data From Database Based On User Input

Jan 18, 2015

I need to take the users input from 2 boxes and reference that to a sqlite database and populate the fields with the data in the database. I know the database code work.

Here is the code for the "user" form;

Java Code:

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import java.awt.Font;

[Code] .....

View Replies View Related

Printing Unfilled Diamond Based On User Input

Jan 31, 2015

I am new to learning Java and I am trying to print an unfilled diamond using asterisks. The height of the diamond has to be based on user input. My code currently prints out a filled diamond based on user input but I cannot figure out how to print an unfilled one. Every time I change one of the loops it messes something else up.

[public static void diamond(){
int i = 0;
int j = 0;
int k = 0;
int height = 0;

[code]...

View Replies View Related

GUI To Display Search Results Based On User Input Server Name

Jul 18, 2014

I am using a GUI to display search results based on user's input server name. I am using MS Access as DB and I have the DSN set up correctly.But the search results are displayed for the first typed value in text filed. I am getting same result set every time though i input different server names .

import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableModel;
public class SearchResult implements ActionListener{

[Code]...

View Replies View Related

Swing/AWT/SWT :: Taking Inputs Based On Previous User Input

Jun 7, 2014

I'm developing a Swing application for the first time. To test my application, I have currently hardcoded some text labels and fields in a JPanel, so that a user can enter input details for a maximum of 3 segments. But this limits the maximum number of segments to 3. However, the requirement is that when the user enters the number of segments (could be greater than 3 as well), corresponding number of input sets need to be taken.

Screenshot attached, with values entered.

Basically I want to know how I should go about taking the inputs from the user.

View Replies View Related

Servlets :: Generate M By N Multiplication Table Based On User Input

May 8, 2014

I have a basic html form with one user input text box labeled "Enter a number" and a submit button labeled "Create a multiplication table". This is the working with a servlet to display an html formatted multiplication table. Everything else is working fine just the formatting is off; I can't seem to get the top row and far left column to number properly. It should look like this with the top row of numbers beginning with a blank cell and then numbering 1 thru n (depending on what the user selects. The first column should be the same, a blank cell and then 1 thru n. Then the multiplication table should be in the rows/columns of the table. Picture this:

I can't get mine to start with a blank cell in the top left-hand corner, instead it has 1 in that cell and the table starts calculating with 2x2.

Servlet code:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

[Code] ....

View Replies View Related

1D Arrays List Of Numbers From User Input?

Dec 4, 2014

Write a program to maintain a list of the high scores obtained in a game. The program should first ask the user how many scores they want to maintain and then repeatedly accept new scores from the user and should add the score to the list of high scores (in the appropriate position) if it is higher than any of the existing high scores. You must include the following functions:

-initialiseHighScores () which sets all high scores to zero.

-printHighScores() which prints the high scores in the format: “The high scores are 345, 300, 234”, for all exisiting high scores in the list (remember that sometimes it won’t be full).

-higherThan() which takes the high scores and a new score and returns whether the passed score is higher than any of those in the high score list.

-insertScore() which takes the current high score list and a new score and updates it by inserting the new score at the appropriate position in the list

View Replies View Related

Checking If Matrix Is Upper Or Lower Triangular Matrix Based On User Input

Dec 5, 2014

java program that will determine if the matrix is a lower or upper triangular matrix. I only need to use java.util.Scanner;.

View Replies View Related

Get Grid Method That Gets Input From User

May 9, 2014

I have a get grid method that gets input from the user. I also have a display grid method that is supposed to display the get grid method but it doesn't. What do I do to make the display grid method work properly. I am not allowed to use a main method.

private int a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4;
public void getGrid ()
{
System.out.println();
System.out.print ("Enter Row 1: ");
a1 = i.nextInt();
a2 = i.nextInt();
a3 = i.nextInt();
a4 = i.nextInt();
System.out.print ("Enter Row 2: ");
b1 = i.nextInt();
b2 = i.nextInt();
b3 = i.nextInt();
b4 = i.nextInt();

[code]....

View Replies View Related

Generate QR Code From Input Text And Display Information About Input / Output Bits

Nov 12, 2014

I am trying to write a program that will generate a QR Code from an input text and also display some information about the input/output bits. So far I have created the frame and what to do next. And I'm not sure if I am on the right track since my level of programming is not that great. By the way, I am using zxing libraries from GitHub. I know, there are plenty of generators online for the QR Code, but that is not what I am looking for. As you can see on the attached image, I am more interested in the efficiency of encoding 2D data. Also, I noticed that almost all the online projects regarding 2D codes are for Android. Which is not very useful.

// QR Code Generator
package qrcode;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

[Code]....

View Replies View Related

Pass User Input - Initializing Array In Method

Feb 7, 2015

I need to pass user input from the main method, which is then validated using another method that is returned as a valid score, and then I pass the valid input to another method that stores the data in an array. The array is initialized within the method. I tried to use an if-else statement to initialize the array, because I originally did this at the beginning of the method. I soon learned that I was creating a new array everything I accessed the method. Needless to say, this isn't working either.

public static void main(String[] args) {
int judges = 7;
float[] validScores = new float[judges];
for (int i = 0; i < judges; i++) {
float score = -1;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Populate JPanel Based On More Information About Selected JTree Node From A File?

Aug 27, 2014

When you select a node in a JTree can you then populate a JPanel based on more information about that node from a file?

View Replies View Related

Adding Information To Array Dynamically

Apr 29, 2015

I'm having trouble conceptualizing something. I will post the code, it's works exactly as it should. I create an array and Hash Map to display periodic table of elements information after allowing the user to search by element name or symbol. I want the user to also be able to add elements to the periodic table. I can't really conceptualize how I am going to do that with an array I've already created.

Here's code:

//Create element objects.
//Here is where I create my "elements" array, and where I could like to prompt the user to add elements, if desicred.
Element[] elements = {new Element("Hydrogen", 1, "H", 1.008,1,1), new Element("Lithium",3, "Li", 6.94,2,1)}; //
//Maybe it seems if I prompt the user here to add new element names, symbols, weights, etc, I would be overwriting

[Code] .....

View Replies View Related

Single Linked List Boolean

Feb 13, 2015

i'm currently studying over single linkedLists and i'm just writing various methods for it. One method i'm currently stuck on is writing a remove method where it returns a boolean true if its found and it will delete it, and false if the target isn't found. My problem is that it always comes up as flase and i know that the target is in the linked list. Here is the code for my method.

Java Code: public boolean remove(E item){
Node<E> ptr = head;
while(ptr!= null && !item.equals(item))
ptr = ptr.next;
if(ptr.data.equals(item)){
ptr.next = ptr.next.next;

[code]...

View Replies View Related

Text Based Game Adding Items

Apr 11, 2014

I am trying to make a text based game. the game has been working perfectly setting up the rooms, first couple of commands, and running it. I am now trying to add items to it but every time it try to run the game it returns :

java.lang.NullPointerException
at Room.addItem(Room.java:107)
at Game.createRooms(Game.java:133)
at Game.<init>(Game.java:28)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

[Code] .....

Here are the classes that matter for this particular situation

import java.util.HashMap;
public class Item
{
private HashMap<String, Item> itemList;
private String name;
private String itemDescription;

[Code] ....

I know that it is the line

itemList.put(item.getItemName(), new Item(item.getItemName(), item.getItemDescription()));

In the game class that is causing the nullpointer exception i just really cant figure out why that keeps happening and how to add the values correctly....

View Replies View Related

Write A Java Program To Store Employee Information In A Linked List

May 12, 2015

Write a java program to store employee information in a linked list, the program should implement the following functions:

The program should display the list of functions, and ask the user to enter the number of function that he/she wants to do, then perform the function as it is required in the previous table.

import java.util.*;
public class Employee {
Scanner in = new Scanner(System.in);
String Name;
String Address;
String Department;
int ID;
int Salary;

[code]....

this is my out put

Please choose a number:
1-Add a new employee
2-Update employee's info
3-Remove employee's info
4-Exit
1
Enter name:
Enter address:
2
Enter department:
3
Enter ID:
4
Enter salary:

now:

1- why are not my adding coming out in the output only the Enter name & Enter address ??

2- how can I add names and ID's and information to test that program

View Replies View Related

How To Change Value Of Boolean Within A Method

Dec 1, 2014

I read in a book that when you change the value of a method parameter that's a boolean or other basic datatype within the method it only is changed within the method and remains the same outside. I want to know if there is some way for me to actually change it within the method. For example:

public class Change {
void convert(boolean x, boolean y, boolean z) { //i want to set x,y, and z to false in this
x = false;
y = false;
z = false;

[code]...

I want to put in part1, part2, and part3 when i call the method than i want them to be set to false within the method. The specific reason i asked this question was because im trying to code a battleship and i have a subroutine class with a method that when its called it checks if a ship has been sunk. If the there was a sink than the method will set a ton of boolean variables to false.

Just to clarify, I want something like this:

void convert(thing1,thing2,thing3,thing4) {
//some code here that sets thing1,thing2,thing3, and thing4 to false
}
// than in main:
boolean test1 = true;
boolean test2 = true;

[code]....

View Replies View Related

Passing A Boolean Parameter From One Method To Other

Jan 30, 2015

Java SE Runtime Environment build 1.8.0..This is part of the code:

public static int addAddress (String[] number, boolean[] front, double[] total) {
int num = 0;
double ffee = 0;
/*boolean value = false;*/
 
[code]...

I have tried using the line of code commented out, /*boolean value = false;*/. However, another error is displayed. The compiler shows the following...

Inspection.java:33: error: incompatible types: boolean cannot be converted to boolean[]
front[num]= defineFront(num, value);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output error...I know that boolean values are by default stored as false, once you create the array. However, I'm having trouble passing the variable to the method.

View Replies View Related







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