Using Double Dimensions Strings And Methods

Apr 17, 2015

i have to use a if loop. I just started using methods and loops..You have been hired as a software developer for Canada’s customs - Toronto Pearson International Airport. Your job is to develop part of the Canada Passport System. The Database Administrator has forwarded to you the database for all the Canadians. For simplicity, assume you only have five records (i.e., only five people on file). These fixed records are the following:

First name, Last name, SIN, Last Date of Entry to Canada, Number of Entries
Mike beee 4567 12-12-1999 7
Jessie weree 4444 07-07-2007 1
Liza veee 2121 05-05-2013 2
Zico qeeee 2444 Never left the country 0

the two dimensional array stores all the values. In addition, all these values should be of type String.The Canadian officer can always see the following four choices:

1) Show custom’s database,
2)Update custom’s database,
3) A summary of a passenger’s record, and
4) Exit.

Choice 1 : always allows the officer to see all the database records (i.e., the five records). Each of these records consists of the following: First Name, Last Name, SIN, Last Date of Entry to Canada, and the Number of Entries (i.e., see the above stored values).

Choice 2 : allows the officer to update the database whenever one of the five Canadian passengers arrives. Once the officer chooses this option, the system will ask him/her for the SIN of the passenger. Then the system will ask for today’s date (i.e., the recent entry date). The system will then reflect those changes on the console screen and the number of entries will be increased by one.

Choice 3: summarizes the record for one passenger where his/her first and last names and last date of entry to Canada will be shown. The last date of entry should only have the last four digits (i.e., only the year). To extract those digits, you should use the String’s method(s). However,before a record is summarized, the records of all Canadians should be shown on the screen in order to allow the officer to choose among those records. Choice 4 allows the officer to exit from the system completely; otherwise the list of choices should be always shown on his/her monitor.This is the code i have so far.

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

double passportInput;
Scanner sc = new Scanner(System.in);
// public static int generalList() // to show the list of choices and return the chosen option
//
// public static void updateRecords(int recordSize, String[][] passportDataBase) //to update the records
//

[code]....

View Replies


ADVERTISEMENT

Convert Strings To Double Numbers - Exception When Non-numeric Entered

Nov 11, 2014

So I have to convert strings to double numbers and there can be no exception.

The strings that aren't numbers or do not fit into a set criteria have to be discarded.

When I try to write this I get an exception when a non-numeric is entered and the code stops.

What can I do? Also, am I finding the average of the array correctly?

import java.util.*;
public class Grades{
public static void main(String args[]){
int arraycount = 0;
final int SIZE = 10;
int validArraycount = 0;
final int ValidArraySize = 10;

[Code] ......

View Replies View Related

Passing Strings In Methods

Mar 16, 2014

I am trying to call stringToFile in the main method but it throws error saying "incompatible types scanner cannot be converted to string."
 
public static void main(String[] args) {
Scanner keyboard = new Scanner (System.in);
mask(keyboard);
printingString();
fileName(keyboard);
  String completeFileName = stringToFile(keyboard);

[Code] ....

View Replies View Related

Sorting Ascending / Descending Methods Not Working On Double Linked List

Sep 12, 2014

I wrote displayAscending() and displayDescending() methods to this double linked list and it is not working at all. Logically it seems fine to me. I positioned the head in the beginning in the ascending method; created a variable named data1 as an auxiliar variable so it can store the values that are going to be moved; and moved the values. Same thing for the descending method but instead of the head I put the tail and move left the list, instead of right.

import java.util.*;
class node {
int data;
node left;
node right; 
node(int d, node l, node r) {
data = d;

[Code]...

View Replies View Related

Calculator Program - Use Strings And Methods To Include Arrays

Jul 23, 2014

My assignment is to essentially update a calculator program that uses strings, and methods, to include arrays. How to create and call an array that the user defines the size of and then inputs the numbers to fill the array. Here's the example my prof gave us of what the output should look like:

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Dot product
6. Generate random array
7. Quit

What would you like to do? 1

How many values are in the arrays? 3

Enter the values in the first array, separated by spaces:
2 4 6

Enter the values in the second array, separated by spaces:
1 3 5

The result is [3.0, 7.0, 11.0]

How to create an array that would allow the user to define the size of the array and then inputs the values for the array? I'm completely lost. I never should have taken java as an online class.

View Replies View Related

Fix Dimensions Of JPanel

Aug 27, 2014

I'm trying to fix the length of expenses to a appropriate size on my Jpanel but not sure how.

package mybudgetapp;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

[code]....

View Replies View Related

Layout Managers - Matrix Of Buttons At The Dimensions Of Panel

Oct 4, 2014

I have read the API and looked at examples but its not answering my question. Which layout would treat a panel as its own entity. Meaning if I made a method that made a matrix of buttons using GridLayout and returned that panel. Then called the method onto a frame and the buttons would not spread out all over the frame. They would simply stop at the dimensions of the panel. Am I looking for something that is not possible?

View Replies View Related

Java Program To Test Circle Dimensions To Prove Pie

Apr 28, 2015

So in trying to create a circle class, and use the dimensions of that circle (radius, area, etc.) to prove it will equal pie and print (3.141592653589793). This is my code so far it and am getting an error in the last two classes. I know it has to do with Circle(Radius); in the 2nd class but whenever i call upon it, it is assigned to itself. And in the last class im not too sure how to put the B= new b(1,1).

[public class Circle {
private double radius;
public Circle() {
radius = 0;
}
public Circle(double radius) {
this.radius = radius;

[Code] .....

View Replies View Related

How To Find Whether Strings Contained In Array Of Strings Constitute A Similar Character Or Not

Aug 25, 2014

I am having an array of strings and i want to find out whether these strings contained in the array contain a similar character or not.For example i am having following strings in the array of string:

aadafbd
dsfgdfbvc
sdfgyub
fhjgbjhjd

my program should provide following result: 3 because i have 3 characters which are similar in all the strings of the array(f,b,d).

View Replies View Related

Java Number Spiral - Creating 2D Array With Given Input Of Dimensions Of Array

Aug 3, 2014

I am working on a problem where i have to create a 2d array with given input of the dimensions (odd number) of array, along with a number within the array and to then print out all of the numbers surrounding that number.

Anyway, i am working on simply making the spiral, which should look like the one below.

n = 3

7 8 9
6 1 2
5 4 3

where the 1 always starts in the center with the 2 going to the right, 3 down, then left etc. etc. I was able to create the code by starting on the outer edges rather than the center and working my way to the middle, however my code always starts from the top left and goes around to the center where it needs to start from the top right. I am having trouble altering my code to meet this criteria. This is what i have thus far.

import java.io.*;
public class Spiral
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of elements : ");
int n=Integer.parseInt(br.readLine());

[Code] .....

View Replies View Related

Sorting Lowercase Strings Before Uppercase Strings

Mar 26, 2014

I can sort strings in a collection by uppercase and then lowercase though I was wondering if there is any way of doing it in reverse, sorting by lowercase then by uppercase.

View Replies View Related

Conversion From Double To Int?

Nov 30, 2014

I'm having some trouble with a code I am writing for class. I had an 2 errors like this before this one and fixed it by changing int avgRe, avgMiles =0; to double. Now I am getting this error and am stuck on what I need to change. Here is the code:

import java.io.*;
import java.util.*;
import java.text.*;
 public class Reimbursement_3_09 {
 static Toolkit tools = new Toolkit();
 public static void main (String [] args) throws Exception {
 
[Code] ....

This is my error:

[code=Java]
Reimbursement_3_09.java:33: error: incompatible types: possible lossy conversion from double to int
summary (outFile, totalAmount, ctrMiles, ctrMilesgt0, avgRe, avgMiles);
^
Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

View Replies View Related

How To Compare Double

Jun 17, 2014

how can i compare two double values is this correct

Java Code:

public boolean isEqualToD(double s_src, double s_compareTo)
{
boolean flag = false;
try
{
if(s_src == s_compareTo)
{
flag = true;

[code]...

View Replies View Related

Array With Double And Int

Apr 11, 2015

Okey so i want to make an array like this

km = miles
10 6.214
15 9.321
20 12.428

and so on its a converter between km and miles and i have no clue how to do this...

View Replies View Related

Percentage Of A Double

Feb 14, 2014

Java Code:

double Compact=30.50;
double Full=40.50;
double discount=.07;
double FullDiscount= 37.67;
double CompactDiscount= 28.37; mh_sh_highlight_all('java');

My question is how do I configure this so that when / if I need to change the discount value, it automatically adjusts the % discount off of the Full or Compact?

All I can get to work is simply hardcoding it and assigning the discount value, i'm probably just messing up the syntax.

View Replies View Related

Cannot Cast From Object To Double

Nov 9, 2014

ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("js");
String expres = calc.getText().toString();
calc.setText(expres);
try {
calc.setText(((double)engine.eval(expres)) + "");
} catch (Exception e) {
}

This line: calc.setText(((double)engine.eval(expres)) + "");

*The error message for this line: Cannot cast from object to Double

View Replies View Related

Double To Hex String Conversion

May 8, 2014

I am trying to convert the double 4270571936.0000000000d to a hex string using Double.toHexString() and the answer I'm getting is 0x1.fd17834p31, what does p stands for?

The answer I'm expecting to get is 0x41efd17834000000 so not sure why it won't give me the correct answer?

The following floating point Double to hex calculator shows the write answer right Floating Point to Hex Converter

View Replies View Related

JSF :: How To Confirm A Field Only Contain Double

Jun 30, 2014

I have a jsf page.i need to confirm one filed only contain double value.how to validate this? I checked and found there is a validateDoubleRange,but its not suitable for this.

View Replies View Related

Cannot Convert From String To Double

Oct 4, 2014

//Students Full Name
firstName = JOptionPane.showInputDialog("Enter student " +
"first name.");
lastName = JOptionPane.showInputDialog("Enter student " +
"last name.");
// Get test grade (numbers)
[b]test1 = JOptionPane.showInputDialog("Enter test1 grade")[/b];

The line in bold is where that error comes up. I know it something simple but I can't remember. I declared both firstName and lastName as Strings and then the test1 I declared as double. I had a similar error in a previous assignment where I had a integer(age) input and then i had an output statement asking for a name all I needed to do was put keyboard.nextLine(); after my age input and I was fine.

View Replies View Related

Conversion Char To Double Value

Mar 31, 2015

I need to understand the java Conversion.

I have a char[] containing ASCII characters that need to be converted into int value and double value.

The int value are always stored in 1 char size like 'j'. I extracted it succesffully by converting the char in a ascii bytearray and then used: Integer.parseInt(sb.toString().replace("0x", ""), 16);

How can I get the Value as double when i used the char[] with size 2 or 4 ?

Example : final char[] charValue = { 'u', ' ', '}','+' }; what is the associate Double value ?

Example : final char[] charValue = { 'T', ' ' }; what is the associate Double value ?

Example : final char[] charValue = { 'T', ' ' }; what is the associate int value ?

View Replies View Related

Typing Double Name In The String

Oct 26, 2014

I am making a program where the user types in how many students, the student name and the student result. My problem is typing in a dobule name for instance: Tom Tom.

I have tried both:

String name = input.Next(); -> Only works with one name.
and
String name = input.nextLine(); -> Skips right trough and ask me to type result again.

Here is my code:

Java Code:

import java.util.Scanner;
public class c5e8 {
public static void main(String[]args){
Scanner input = new Scanner (System.in);
int highestResult = 0;
String highestName = " ";

[Code] ....

View Replies View Related

What Is Difference Between Float And Double

Jan 31, 2011

What is the difference between float and double?

View Replies View Related

How To Use Public Double GetXCoordinate

Dec 9, 2014

I am trying to understand a question:

R2 (x,y) -- Make the Point class code that implements a corresponding abstraction to a given point in R2. You should explicitly provide the manufacturer's code P (double x, double y) for the Point class. And code for the methods, whose definitions are:

- public double getXCoordinate ();
- public double getYCoordinate ();
- public setXYCoordinates (double x, double y);
- public moveTo (double x, double y);
- public printAtts ();

View Replies View Related

Double Number Formatting

Oct 29, 2014

I have a real number. example:

double number = 1.95842175;

I want to split it into 2 integers:

int a1 = 1;
and
it a2 = 95 (2 numbers after '.')

How?

View Replies View Related

Program Conversion Int To Double

Apr 20, 2015

I am working with a java program that uses binary and sequential search. i have those two methods working. In the program i also need to return the price of parallel arrays. This is my code so far:inventory class:

//FileName: InventoryData.java
//Prog: Brock Paston
//Purp: To load and search through arrays with binary and sequnetial search.
package stu.paston.program6;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

[code]....

View Replies View Related

Sorting 10 Double Arrays

Sep 17, 2014

I'm trying to sort 10 inputted numbers (double precision) using the Array.sort() method. I can get the 10 numbers inputted, but the output is ten 0.0s; now (and this how I know I am learning some things) I'm fairly certain that the variable number is not storing the numbers inputted by the user otherwise I wild be seeing the program work correctly.

So my question is why isn't number storing the inputs?

import javax.swing.JOptionPane;
import java.util.Arrays;
public class KrisFrench3 {
public static void main(String[] args) {
double[] number = new double[10];
for(int i = 1; i <= i; i++) {

[Code] .....

View Replies View Related







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