How To Calculate Parking Rates

Mar 31, 2015

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.

View Replies


ADVERTISEMENT

Create Parking Program

Nov 8, 2014

i need to crate a Parking program

Java Code:

import java.util.*;
class xxx
{
public static void Parking (String args[])
{

Scanner snip = new Scanner (System.in);
System.out.println("Enter time:");
int Enter_time1;
int Enter_time2;
Enter_time1= snip.nextInt();
Enter_time2= snip.nextInt();

[code]....

View Replies View Related

Program That Calculates Parking Fee

Oct 23, 2014

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.

View Replies View Related

Create And Report Ticket In Parking Meter Class

Sep 12, 2014

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

[Code]....

View Replies View Related

MVC Calculator - How To Get It To Actually Calculate

Sep 28, 2014

I made a MVC calculator. I was wondering if you could take a look at my design and if I was on track. I am still working on getting it to actually calculate something. All the buttons respond and print text on the JTextField but it is not calculating.

package calculator.MVC;
import javax.swing.JButton;
import javax.swing.JTextField;
public class CalculatorModel {
private int sum;
private int number;
private char opt;

[code]....

View Replies View Related

Calculate (C) How Is The Result 3

Apr 3, 2013

public class NewClass4 {
public static void main(String[] args) {
int a = 1;
int b = 2;
int c = 3;
a += 5;
b *= 4;
c += a * b;
c %= 6;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);

View Replies View Related

Calculate Radius Of A Pond?

May 31, 2014

This is the code

public class PondRadius {
public static void main (string[] args) {
//Calculate the radius of a pond
//which can hold 20 fish averaging 10 inches long
int fishCount = 20;//number of fish in pond
int fishLength = 10;// Average fish length
int inchesPerFoot = 12;//number of inches in one foot

[Code] ....

And here is the error or exceptions i received

C:javaLesson1>javac PondRadius.java
PondRadius.java:23: error: ')' expected
System.out.println("To hold" + fishCount + fish averaging " + fishLength +" inch
es long you need a pond with an area of
" +

[Code] .....

View Replies View Related

Calculate Lowest Value Of Array

Feb 13, 2015

So I have this code to calculate the lowest value of an array:

public class Exercise1 {
public static void main(String[] args) {
int[] theArray = {1/*/,2,3,4,5,6,7,8,9,10/*/};
int result = Exercise1.min(theArray);
System.out.println("The minimum value is: " +result);

[code].....

and I need to write an exception class that should be thrown if the array does not hold any elements.

View Replies View Related

How To Calculate Difference Between Two Dates

Oct 19, 2014

I have been tasked with creating an invoice (school assignment). Part of the calculations is creating an interest depending on the amount of days between the current date entered, and invoice date entered (The program prompts the user to enter both the current and invoice dates by asking for the day, month and year).

We are also supposed to set the contructor to a default date of 1/1/1900.. but I don't know how or where to code that.

How to calculate the difference between the CurrentDate and Invoice. I have displayed the dates to the user as follows.

public void displayDate() {
System.out.println("
Today's Date: " + month + "/" + day + "/" + year);
}
public void displayInvDate() {
System.out.println("
Invoice Date: " + invMonth + "/" + invDay + "/" + invYear);

View Replies View Related

How Does Program Know To Calculate For Only One Year

Mar 26, 2015

how does the program know to calculate for only one year?

public class Interest2 {
public static void main(String[] args) {
double principal; // The value of the investment.
double rate; // The annual interest rate.
double interest; // The interest earned during the year.

[code]....

View Replies View Related

Calculate Minimum And The Maximum

Nov 21, 2014

i need to calculate the minimum and the maximum, actually it seems to be easy but, the minimum should be the smallest number but 0..this is my code

Java Code:

Scanner s = new Scanner (System.in);
int max = 0 ;
int min = 0 ;
System.out.println(" Please enter 3-5 numbers");
int a = s.nextInt();
int b = s.nextInt();
int c = s.nextInt();
int d = s.nextInt();
int e = s.nextInt();

[code]....

View Replies View Related

Calculate Sum Of All Integers Between 1 And Given Integer N

Aug 3, 2014

So I wrote a method that simply calculates the sum of all integers between 1 and a given integer n. The method works fine however, as n gets big the solution will have time and space problems. Some I'm just curious if there is a better method than my iterative one that would produce a better Big O value.

public static int sum(int n)
{
int total = 0;
for (int i = 1; i <=n; i++)
total += i;
return total;
}

View Replies View Related

Calculate Percent In Java

Jan 3, 2014

I would like to change the precent from *1.17 (17%) to calc of precent like this :

3% + 5% + 5$

For example :

The resault is 10$ - i want to get :

10$ +3%(0.3$) + 0.5% (0.51$) + 5$ = 15.81$

How i change this line to this calc

if(results[i].getSite()=='Xxx'&&XPrice==0)
{
XPrice =(results[i].getPrice() *1.17);
}
}

View Replies View Related

Using For Loop To Calculate Power?

Oct 16, 2014

I'm new to java and i'm trying to figure out how to calculate power in java using the for loop.

The geometric sequence is (d*c^(n-1)).

So it goes d, d*c^1, d*c^2,......., d*c^(n-1)

??????for (i=1; i<=n; i++){

result

}????????

How to program this. how do i write this using for loop?

View Replies View Related

Calculate Value Of PI Using Series Expansion

Jun 18, 2014

Write a program called ComputePi to compute the value of pi using the following series expansion. you have to decide on the termination criterion used in the computation(such as number of terms used or the magnitude of an additional term). Is this series suitable for compute pi?

PI=4*(1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)-(1/15)+.......)

View Replies View Related

Calculate If Code Matches

Jan 19, 2015

I have for example a letter code "EECC"...Now i want to have a good loop that checkes if the code typed in by the player matches or not? For example if player types CECE it should say it matches because C occurs 2 times and E occurs 2 times. This function must return than 4.If player types CEEE, it must return 3, because the code has 2 C en 2 E, player input is 1 C and 3 E, the last E is wrong.I've tried some loops with breaks but they all fail..

for example:

String test = "EFCC";
String test3 = "ECEC";
for(int i = 0; i < test.length(); i++){
matchFound = false;

[Code] .....

This returns 2 instead of 3.

View Replies View Related

Find Min And Max Values And Calculate Mean For Data Set

May 2, 2014

The first is MyArray Class (You can either use an array or an arrayList)Create a class called LastNameFirstNameMyArray according to the UML diagram. This class will allow a user to enter 5 integer values into an array(or object of ArrayList<Integer>). It contains methods to find min and max values and calculate the mean for the data set.

LastNameFirstNameMyArray - data[ ] : int (or data : ArrayList<Integer> )
- min : int
- max: int
- mean : double + LastNameFirstNameMyArray()
+ findMin() : void
+ findMax() : void
+ calculateMean(): void
+ toString() : String

Attributes:
data[]the array which will contain the values or data<Integer>the arraylist which will contain the values
minthe minimum value among the values in the arraylist
maxthe maximum value among the values in the arraylist
mean the arithmetic average of the values

Methods:
You need to implement the constructor LastNameFirstNameMyArray(), which populates 5 values. In addition, the constructor should call findMin() and findMax(), and also calculateMean().

Methods:
LastNameFirstNameMyArray()the constructor. It will allocate memory for the array (or arraylist) of size 5. Use a for loop to repeatedly display a prompt for the user which should indicate that user should enter value 1, value 2, etc. Note: The computer starts counting with 0, but people start counting with 1, and your prompt should account for this. For example, when the user enters value 1, it will be stored in indexed variable 0. The constructor should populate 5 integer values, call findMin() and findMax(), and also calculateMean().

findMin()this is a method that uses a for loop to access each data value in the array (or arraylist) and finds the minimum value. The minimum value is stored into min.

findMax()this is a method that uses a for loop to access each data value in the array (or arraylist) and finds the maximum value. The maximum value is stored into max.

calculateMean()this is a method that uses a for loop to access each data value in array (or arraylist) and add it to a running total. The total divided by the number of values (use the length of the array), and the result is stored into mean.
toString()returns a String containing data, min, max, and the mean.

Task #2 TestMyArray

1. Create a LastNameFirstNameTestMyArray class. This class only contains the main method. The main method should declare and instantiate a LastNameFirstNameMyArray object.
2. Compile, debug, and run the program. Then, it should print out the contents, the min, max, and mean of the data.

and the second is A theater seating chart is implemented as two-dimensional array of ticket prices, like this:

10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
20 20 30 30 40 40 30 30 20 20
20 30 30 40 50 50 40 30 30 20
30 40 50 50 50 50 50 50 40 30

Write a program that prompts the users to pick either a seat or price. Mark sold seats by changing the price the 0. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price.

Note: Assume that if the user enters 1 for the row and 1 for the seat, the yellow marked sit will be sold.

View Replies View Related

Calculate Coupon Discount In Java?

Feb 9, 2015

i finished up a project here and seem to be running into some issues. I figured its my notation, when i ask a user to enter a number, if its below 10, it should *only* print "No Coupon." but what appears to happen is that the program prints "No Coupon" Plus the "discount coupon and % of purchase."

import java.util.Scanner;
public class assign1c { /* Start of Class 1c */
static double cost;
static double coupon = 0;
static String x = "No coupon";
public static void main(String[] args) {
// TODO Auto-generated method stub

[code]...

View Replies View Related

Loop To Work With Formula To Calculate New Value Of CD

Jan 28, 2014

It's suppose to generate a table with the month, and the new amount of the CD. Right now, the program generates a continuous table for months, but it doesn't update the value of the CD.

import java.util.*;
public class Excercise04_31 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);

[Code] ....

View Replies View Related

How To Calculate Sinus / Angle Between Two Points

Dec 11, 2013

I need to know the sinus or angle between two points (x1,y1) and (x2,y2).

Any formula to calculate this?

View Replies View Related

Calculate Price And Quantity With Or Without Discount?

Oct 24, 2014

double price;
String PriceStr;
int quantity;
String QuantityStr;
PriceStr = JOptionPane.showInputDialog("Enter the price: ");
price = Double.parseDouble(PriceStr);
QuantityStr = JOptionPane.showInputDialog("Enter the quantity: ");

[code]....

So i tried to make it allows the user can continue pick the option and calculate the total of every time they select the option, mine is only 2 times.

View Replies View Related

How To Calculate Data Transfer Speed

Feb 25, 2014

Two machines are connected in a LAN & Sharing Files in between them.

Everything is Working Fine but now i want to calculate the Copying Speed/data transfer Speed between them.

View Replies View Related

Calculate GPA And Sort A Column In CSV File

Jan 30, 2015

I am having a hard time compiling this code: I need to calculate the gpa of each student in the csv file which looks like this:

ID First Name Last NameClass LevelDesired ClassCreditsPoints GPA
9410917 Reagan Walls SophomoreCOMP 18275 77 1.026667
13498070 Stewart Fry Senior COMP 10070 92 1.314286
37500410 Talon Witt Junior COMP 100107 389 3.635514
47845461 Ciara Beard Grad COMP 11097 196 2.020619

The GPA column needs to be added by dividing the points by credits. I also need to sort the class level column by class level. For example:

ID First NameLast NameClass LevelDesired ClassCreditsPointsGPA
9410917 Reagan Walls SophomoreCOMP 18275 77 1.026667
46309070 Ivy Valdez SophomoreCOMP 1006 16 2.666667
37405616 Miriam Welch SophomoreCOMP 11057 179 3.140351

Here is my code:

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.String;
import java.io.File;
import java.io.PrintStream;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.FileOutputStream;
import java.util.Comparator;

[code]...

I am taking the two things that needed to be outputted, one at a time. Working on the GPA portion.

View Replies View Related

Calculate Sum Of Integers Mentioned In String

Mar 3, 2015

So this I need to write a program which asks the user to enter any string, but the string has to have integers inside. I need to calculate the sum of those integers mentioned in the String. Also return 0 if there aren't any.

User input: I have a 91
Output: 10

I cant seem to find a way scan through the string to find the integers and add them.

String x1=input.next();
char digit= x1.charAt(3);}
public static int findDigitSum (String x)?

View Replies View Related

Create A Program That Will Calculate Different Tax Brackets

Oct 3, 2014

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

[code]....

View Replies View Related

Trying To Calculate Fine Using Method Calls

Jul 3, 2014

I am trying to calculate a fine in a PoliceOfficer object with method calls to a ParkedCar and ParkingMeter object. The word problem is:

The fine is $25 for the first hour or part of it and $20 for every additional hour of part of it.

My code is:

public class PoliceOfficer
public static final int PARKING_FINE1 = 25;
public static final int PARKING_FINE2 = 20;
public static final int NUMBER_OF_MINUTES_OVER_PARKED = 60;
public double calculateFine(){
double calculateFine = 0;

[Code] ....

obviously the fine is not calculated correctly but I'm not sure how to proceed from here...

View Replies View Related







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