Driver For Lockable Coin Class?
Feb 20, 2014
I am having trouble creating a driver for the following program. im new to creating interfaces and i need to make this work.
Lockable interface:
Java Code:
public interface Lockable {
boolean locked();
public void setKey(int key);
public void lock(int key);
public void unlock(int key);
} mh_sh_highlight_all('java');
[code]....
View Replies
ADVERTISEMENT
May 2, 2014
Why we create a driver class?Instead of creating a driver class, if we want to compile our code so will it show output? Let say, we've created a class GradeBook of the institution for students.So they can easily view their profile information and scores in different semesters.so when we have created a class for this purpose, should we create a driver class or not?What is the big advantage of creating a driver class?
View Replies
View Related
May 14, 2015
I came across the below
1) When a variables are declared "Private" How should it be accessed from the driver class ? Sometimes i get an error in driver class saying "your variable is declared Private" why am I getting this error ...
The document says "Private" declared variables should be accessed only through methods. What does that mean.
View Replies
View Related
May 10, 2014
public class Car
{
//instance variables ----------------------
private String make;
private String model;
private int year;
private double vehiclePrice;
private double downPayment;
private double milesPerGallon;
[code]....
I created this class "Car" (also not sure if it's correct) and need to write a driver program that creates two instances of the class Car. One must use the default constructor, and the other must use the non-default constructor. It must demonstrate the methods used in the Car class using those instances.
public class DriverCar
{
public static void main(String[] args) {
Car car1 = new Car("Toyota", "Corolla", 2013, 20000, 3000, 35);
Car car2 = new Car("Ford", "Taurus", 2005, 14000, 1500, 25);
System.out.println(car1);
[Code] ....
View Replies
View Related
May 13, 2014
Assignment:
Create a class; call it Lab4a that will have one method called pull. This method does not return anything and requires no parameters.
-In the method, create three random integers in the range 1 to 7. The method will then display the three numbers to the terminal window.
-Now create a driver program, called SlotMachine, to invoke the pull method of the Lab4a class.
-As a refresher, you will have a main method in the driver class that will create an object of Lab4a and then use the only method of this object.
-In your driver program, invoke the roll method 10 times.
-See the back of this lab for an example of the output.
This is what I have so far.
Slot machine
import java.util.Random;
public class Lab4a {
public static void main (String[]args) {
Random pull=new Random();
[code]....
View Replies
View Related
May 5, 2014
Okay, so I have to create a class with instance data and instance methods.
First, BankAccount class. It should contain the following information, stored in instance variables:
First name: The customer's first name.
Last name: The customer's last name
Balance: The amount of money the customer has in the account.
It should have the following methods:
BankAccount(String firstName, String lastName,
double openingBalance)
This constructor creates a new BankAccount
public String firstName()
Returns the customer's first name
public String lastName()
Returns the customer's last name
public double balance()
Returns the customer's account balance
Finally I need to create a driver to test my class. And create several accounts and verify that the first name, last name, and balance methods work properly. This is my code below.. I don't know if I did it right.
public class BankAccount {
String firstName, lastName;
double balance;
public BankAccount(String firstName, String lastName, double balance) {
[Code] .....
View Replies
View Related
Apr 13, 2015
I am to create a Array class then create a Driver class (TestArray) to test all the methods in the Array Class. Here's the code i've written for the Array Class. I just nee developing the TestArray class.
import java.util.Scanner;
public class Array
{
Scanner sc = new Scanner(System.in);
private double[] array = new double[];
public void setArray(double[] arr) {
[Code] ...
View Replies
View Related
Oct 30, 2014
I have a driver and a main program. How would I go along with calling the encode method to the driver class that I made so I can have the user inputs affected by the encode method?
Java Code:
public class ShiftEncoderDecoder
{
private int shift;
public ShiftEncoderDecoder(int shift)
{
setShift(shift);
}
public int getShift()
[Code] ....
View Replies
View Related
May 1, 2014
i am trying to write a coin program:Write a class called Coin which will be used by a program called CountFlips.
1. The class, is an object created from this program. It is composed of data values and methods. It should contain a main method and should output the number of flips done (an integer that will be read from the user), the number of heads and tails that occur.
2. The CountFlip class will flip a coin multiple times and counts the number of ‘heads’ and ‘tails’ that result. This class should have a method called flip() of type void; a method called isHead() of type Boolean and a toString() method that will return the current face of the coin as a string.
So i created 2 classes, one called Coin.java & the other CountFlips.java,
PHP Code: package test;
public class Coin {
private final int heads = 0;
private final int tails = 1;
private int facetype;
private int flips;
[code]....
View Replies
View Related
Feb 2, 2015
I am trying to create a program that asks you the number of times you want a coin to be tossed, and then outputs the number of times it "landed" on heads in that inputted number of times. I want it to output something like "number of heads:". Instead my program outputs multiple lines saying "number of heads: *a number*" or "number of tails: *a number*".create the output I want by modifying my program?
Java Code:
import java.util.Scanner;
public class Lab04
{
public static void main(String [] args)
{
Scanner in;
in = new Scanner(System.in);
[code]....
View Replies
View Related
Oct 13, 2014
I have been tasked with creating a coin Star simulator. This accomplishes which accomplishes the following tasks:
Prompts the user to enter coins:
(example inputs): (Note, these can't be like a numerical input followed by a word input, it needs to be one line)
4 quarters
3 dimes
0 pennies
All of which would be allowed inputs.
If an incorrect format is used it should tell the user to use the correct format of number space cointype
After every new input it should give a running total of the current money the system has stored.
this loop should continue until the user enters the phrase "finish"
Then, this system should output the money (minus 9.1% fee) in the largest denominations possible (up to $20)
So if the total came to $ 131.33 (after fee)
It should output:
6 twenties 1 tens 0 fives 1 singles 1 quarter 0 dimes 1 nickle 3 pennies.
and then maybe some cheeky text about how the machine stole your money.
The actual coding for me however is very difficult as I really don't know how to convert the string input from the user into usable numerical and substrings for the calculations.
I have some basic skeleton code worked out, but its only designed to run once.
import java.util.Scanner;
public class CoinStar {
Scanner input = new Scanner(System.in);
public static void main(String[] args) {
/** this first section is supposed to take the string from the user and separate it into two substrings,
* one integer, one word string
*
[Code] ....
View Replies
View Related
Jan 2, 2015
what im trying to do is modify the Coin class to override the toString() method so that it indicates whether the coin is face up or face down. For example, "The coin is face up." This is what i have so far:
public class Coin {
public static void main(String[] args) {
Coin coin = new Coin();
for (int i = 0; i < 1; i++) {
coin.flip();
System.out.println(coin);
[Code] .....
View Replies
View Related
Apr 3, 2014
I'm having some issues getting this code to reject negative numbers. What I'm doing wrong.
import java.util.Random;
import java.util.Scanner;
public class ForLoop
{
public static void main (String [] args) {
Random randomNumber = new Random();
[Code] ....
This is what I have so far..
View Replies
View Related
Apr 22, 2015
I am supposed to write a static method that simulates a flip of a weighted coin by returning either heads or tails each time it is called. The coin is twice as likely to turn up heads as tails. My idea was to of course use a random class
Random flip = new random
and somehow initialize it so 3 numbers are called and create if statements so that when 0 and 1 are called heads returns and when 3 is called tails is.How do I put all this together?
View Replies
View Related
Mar 26, 2014
I am trying to flip a coin 1000 times and make the driver class count the number of times a head and tails appear. However, I am having some trouble trying to figure out the error:
package Week5;
import java.util.Random;
public class Coin {
private int heads;
private int tails;
private int face;
[Code] ....
I was able to print out the generated numbers, but java will print either heads or tails a thousand times and count that as 1000 and nil for the other probability...
View Replies
View Related
Nov 19, 2014
I cannot figure out why my buttons don't work. I believe my problem is in the flip function. I am very new to programming and I am about as good at code logic as I am at real logic lol. Also I am lost on how to go about making the coin stop on a random heads or tails.
Coin cF;
void setup() {
size (600, 600);
cF = new Coin(0,0,0);
}
void draw() {
background(100,100,100);
//Coin(int lX,int lY, int cSize)
//location(int l_x, int l_y)
//flip()
[Code] ....
View Replies
View Related
Jul 26, 2014
Where do I have to put the ojdbc6.jar file so that Java finally recognizes it?I'm trying to connect to a Oracle XE databse from a Java application, but
Class.forName("oracle.jdbc.OracleDriver");
Will throw a ClassNotFoundException no matter where I put the driver. Stuff like this should be extremely simple but I am about to give up for good now.
View Replies
View Related
Sep 25, 2014
I'm trying to use a setter method to pick a random integer to be the MPG for a car. However, I'm having major issues in my driver when trying to use that random number in an instance. I'm not finished with the driver yet because I keep getting "cannot find symbol errors"
import java.util.Random;
public class Car {
private String make;
private String model;
private int year;
private int mpg;
private int odometer;
Random generator = new Random();
[code]...
View Replies
View Related
Feb 25, 2014
I want to write java code which can block unbuffered I/O requests send to CD driver ...
View Replies
View Related
Mar 22, 2015
I started learning mysql to connect my program to a database but every time i try to connect I get this error.
java.sql.SQLException: No suitable driver found for dbms:mysql://localhost:3306/apexdemo
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at JDBCdemo2.main(JDBCdemo2.java:7)
I did the following:
- added the mysql-connector-java-5.1.34 jar to my classpath
- added mysql jdbc driver to the project library
- double checked the url syntax and spelling errors
- checked that the server is running
import java.sql.*;
public class JDBCdemo2 {
public static void main(String[] args) {
Connection conn = null;
[Code] ....
View Replies
View Related
Jan 6, 2015
I wrote a couple classes and am trying a test driver but it is having an error I do not know how to solve.
Student Class:
public class Student{
private Course[] courseList;
private static int numCourses;
private final int maxCourses;
public Student(int max){
maxCourses = max;
[Code] .....
Error:
javac tester.java
tester.java:6: error: cannot find symbol
one = new Course(name);
^
symbol: variable name
location: class tester
1 error
Same issue, just only one error as there is only one line. It seems like it does not accept my parameters as it cannot find symbol.
I forgot to put the "" in the brackets, it's been a month since I have looked at any java and made this simple mistake.
View Replies
View Related
Oct 15, 2014
I need to access Oracle database without using ODBC driver using DAO only, how to do that...
View Replies
View Related
Jan 15, 2015
I'm working on an application I made a few years ago. At that time I connected to a local database so my address was 'jdbc:mysql://localhost:3306/'. That database is long gone so I recreated it on one of my hosted servers but I'm a little unsure of how to connect to it. At the moment I'm trying "jdbc:mysql://www.mydomain.com:3306/" but it is giving me an access denied error.
java.sql.SQLException: Access denied for user 'myusername'@'c-[my-ip].hsd1.pa.comcast.net' (using password: YES)Every result on Google seems to use localhost so I'm having a little difficulty figuring out the correct format.
View Replies
View Related
Jun 23, 2015
This the output of java from my PC under linux platform (rhel 6.5).
[pentaho@vertica-srv1 Downloads]$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
[Code] ....
But the problem is while trying to open ETL program under linux platform [pentaho@vertica-srv1 data-integration]$ ./spoon.sh .... I received the following error messages.
[pentaho@vertica-srv1 data-integration]$ ./spoon.sh
Trying to add database driver (JDBC): RmiJdbc.RJDriver - Warning, not in CLASSPATH?
Trying to add database driver (JDBC): jdbc.idbDriver - Warning, not in CLASSPATH?
Trying to add database driver (JDBC): org.gjt.mm.mysql.Driver - Warning, not in CLASSPATH?
Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Warning, not in CLASSPATH?
[KnowledgeFlow] Loading properties and plugins...
View Replies
View Related
Nov 7, 2014
We have a java application in our production enviroment using Spring framework which is configured with DBCP connection pool and the backend is Oracle database( version 11.2.0.3). Recently we encountered an occasionally happened situation(about once every week) and can be described as below:
The application schedules a task that runs every 10 minutes. And during task execution, the application would issue a SQL query of which the result is expected to be got within 10 seconds. At 11:51 a.m Oct 13th, however, the application failed to get the result within expected time, and 2 hours later, at 13:51, the result was finally returned to application. Due to lack of information at that time, we were not able to reproduce the same problem in test environment. At 15:31 p.m, Oct 29th, it happend again and this time we grasped all the information including thread dump and Oracle diagnostic information. We could found that:
1. Through oracle v$sql view, we could find that the SQL query is executed twice, at 15:31 and 17:31 respectively.
2. By analyzing TCP packets provided by network monitoring tools, it can be concluded that the request TCP packet containing SQL statement had been sent to Oracle and get executed, but after that JDBC only fetched first 80000 records out of 90000 records in total and then it stopped, didn't send any more request to Oracle to fetch rows. 2 hours later, Oracle sent a TCP keep alive packet and JDBC driver resume fetching remaining rows using the same connection(which can be confirmed by comparing source port of packets).
3. We dumped the thread at which JDBC hangs at socket read of JDBC driver
By the way, the version of JDBC we use is 11.2.0.1 and JDK version is 1.5.0_22.
The SQL statement is very simple:
select sum(n.netvalue) npvi,
n.HISCENEID hsid,
n.counterpartyid cid,
n.productid pid,
n.opendays
[Code] .....
View Replies
View Related
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