I am having trouble creating the for loop in the Parking Simulator. I dont even know where to start. I have searched google and I havent found any Parking simulators that used array lists. Here are the requirements:
The ParkingSimulator Class: This class should simulate checking the parking tickets. You should loop through the cars, choose a random officer, and have that officer check to see if there is a parking violation. If there is a violation, add it to the ParkingTicket ArrayList. After all have been checked, print out a summary of the tickets (using the toString() from the ParkingTicket class).
I think I have all the classes right except for the ParkingTicket Class which I know is screwed up in the for loop because I cannot get the random officer and create and report ticket if mins were over maxlimit and it is printing the whole string of officers when it should be picking one officer at random to assign to the ticket. Also it is not printing out the whole output.
output should look like:
VW with license # N34234 parked for 60 minutes at PM1 and a maximum time limit of 90 minutes - no violation. Reported by officer Joe badge: PO123
Mazda with license # 234-567 parked for 70 minutes at PM2 and a maximum time limit of 60 minutes was parked illegally for 10 minutes for a fine of 25.0. Reported by officer Sam badge: PO812
etc;
Summary of tickets: License:234-567 at meter #:PM2: Fine: $25.00 License:W879HY4 at meter #:PM4: Fine: $25.00 License:BG65RF7 at meter #:PM5: Fine: $25.00
I succeed but with limit. the code is below. I cant use advanced material (really just the basics even without loops)
if statements are allowed, and i must use Final variables for key value.
I must use one class and one method (the main}|). I need to prompt the user for a entrance time and exit time, it must be with a space , like 18 00 and not 18:00
Also, if the entrance time is greater or equal to 18 00 the charge is always 20 dollars. If the user enters wrong data or out of range data an output of "ERROR WRONG DATA" and then the programs terminates. Same for wrong time . like if the enter hour is bigger than the exit hour an output of "ERROR entrance time must preccede exit"
for the first hour the output is "no charge", for the second hour the charge is 10 dollars. from the 3 hour for every 15 minutes an additional fee of 3 dollars.
for example if the user entered 10 00 and 13 20 , it should be 52 dollars
** it works for me but if the difference between the entered and exit hours is more then 3 it doesnt work. I could've added another if statements for the bigger hours but it will be very long.
I managed everything. except the last part. That calculates additional 3 dollar for each 15 minutes. what is did is.
converted everything to minutes.
subtract enter time from exit time.
and divide by 15.
thats give me the number of 15 minute periods.
if it last or equal to 4. no charge
else last or equal to 8 . 10 dollars
else...... here is the hard part.
if the total minutes wont divide even by 15 it wont work.
there are the normal parking rates with two condition using two difference code and two difference calculator method. the fees for the two code also different.i need to display the code, enter time. enter out, and parking charge. i have a problem with the processor method.
Ive been trying to create a program to say how many 5cent,10 cent and 50 cent coins there are if you put a number in example 20. I used the init method because thats what the teacher told me to use but i have no clue on what to do.
I am now at the beginning trying to teach myself Java :) So far it has been good everything however now I came across the problem where I wanted to create payroll program for myslef based on one of the books I have.Somehow the issue in provided program code gives me the negative values on the salaryNett and valueTax:
Java Code:
import javax.swing.JOptionPane public class FinnancialApplicationPayroll { public static void main (String[] args){ String input = JOptionPane.showInputDialog (null, " What is your name");
I'm just learning about arrays. I have a small program to write that asks to create 2 arrays. One holding 5 names of flowers. One holding the prices of those 5 flowers. I ask the user what kind of flower they want and the quantity. I then need to create a loop that locates the flower name and uses that index to find the cost of the flower. I am struggling on how to write in code how to use one array index to find another. Example: Roses and $.50.
We have to create a program called MyStack.In Push: Add one element at the end of the buffer.In Pull: Remove one element from the end of the buffer. In isEmpty: Should check if the list is empty or not and return the result as a boolean variable.
I am totally confused, I wrote the buffer and the array, but how do i add an remove element from the buffer?How do i add an element? What Statement do i Use?
Java Code: public class MyStack<T> implements Stack<T> { private final T[] ringbuffer; int index = 0; int last;
I have spent the past 12 hours on it and have gotten no where. I need to create a program that will calculate different tax brackets. I have tried all combinations I can think of and can't get it to work!!! I am literally about to go insane! I need the program to calculate tax will be 1% for anything up to $50000. If the tax is over $50000, you keep that 1% of $50000 and then add the remaining. So for an income in the second range, it would be 1% of $50000, and then 2% of (income - $50000). This then continues for each range.
The problem I'm having is getting it to display the correct interest rates. I am not asking for you to write it for me. I want to learn. But at this point I have exhausted all resources available to me.
import java.util.Scanner; public class Project3taxinfo { public static void main(String[] args) { final double RATE1 = 0.01; //1% tax on the first $50,000 final double RATE2 = 0.02; //2% tax on the amount over $50,000 up to $75,000 final double RATE3 = 0.03; //3% tax on the amount over $75,000 up to $100,000 final double RATE4 = 0.04; //4% tax on the amount over $100,000 up to $250,000 final double RATE5 = 0.05; //5% tax on the amount over $250,000 up to $500,000 final double RATE6 = 0.06; //6% tax on the amount over $500,000
I was told to create a program that prints the time between 00:00 (0:00 a.m.) and 23:45 (11:45 p.m.) in the 24-hour clock and 12-hour clock format like this:
I'm suppose to create a program that will check if one statement is equal to another but it doesnt display the message if its equal to the inputted String
import java.util.Scanner;
public class sup { public static void main (String args[]) { Scanner in = new Scanner (System.in); String one;
[code]...
thats just an example I was able to do it in C++ but it doesnt do what I want in Java
create a program that display video in second monitor ....every time i run my code it display the video in first monitor not in second monitor .. Here my path i used
so I had to create a program that allows the user to enter a day using a number and then enter a year and after they did that it would create an entire calendar for that year ..so I have that but the only issue is I can not get the numbers to line up neatly.how to do the entire thing in loops, I tried a couple in here..what this would look like as loops instead of switches and cases and if else
import java.util.Scanner; public class Calendar { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
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);
Write a program to create an integer array of size 20. Then, the program should generate and insert random integers between 1 and 5, inclusive into the array. Next, the program should print the array as output.
A tremor is defined as a point of movement to and fro. To simulate it, the program will generate a random number between 0 and 19, which represents the location in the array (i.e. index number). Then, the 3 numbers to the left and right of this location should be reset to the value 0. If there isn't 3 numbers to the left and right you may assume a lesser number depending on the boundaries of the array.
Then, the final array should be printed as output. There is no user input for this program.Your program must include, at least, the following methods:
-insertNumbers, which will take as input one integer array and store the random numbers in it. -createTremor, which will generate the random number as the location and return it.
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.
i have a problem in connecting my jsp program in MSsql 2005 i want to create a connection in my jsp program to MSsql database but theres an error of my work here is my code
I am trying to create a program for class the uses two dimensional arrays. I am stuck on the second step that states Use two parallel arrays. One is a two-dimensional array -- a row of this array will hold six values in this order: [0] number of hours worked, [1] hourly pay rate, [2] gross pay, [3] net pay, [4] federal withholding, and [5] state withholding.
This is what I have so far:
Java Code:
double [][] data = new double [30][6]; String [] names = new String [30]; String str = null; String detail = null; int n = input(data, names, inputFile); mh_sh_highlight_all('java'); (there's more but i don't believe it pertains to this question)
My question is how would I create this array. Or, is that right above? I've searched online and in my book and I just don't understand.