Beginning java student traffic violations program

I need some help with a program on traffic violations

Page 1 of 1

5 Replies - 3095 Views - Last Post: 29 January 2009 - 09:40 PM Rate Topic: -----

#1 Toast_Jones  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 29-January 09

Beginning java student traffic violations program

Posted 29 January 2009 - 07:46 PM

Alright. I'm a junior in high school and I've only been coding for a few months. There's this project I have to do dealing with traffic violations. Here are the specifics:


I need to make a program that would allow me to enter the speed at which the offender travels, and the number of tickets they have received. It should provide interface options to allow users to calculate charges and exit the application. It should calculate and display how many miles over the speed limit the offender was traveling, the cost of the speeding ticket, and court costs. It should calculate a charge of $20.00 for each mile per hour over the speed limit. and it should calculate court costs beginning at $74.80 for the first offense and increasing by $25.00 for each subsequent offense stopping at the third....

Now, I know that was a mouthful, but I would really like some help.... I'm trying to wrap my mind around the declaration of variables still, I think I'm over complicating things but all I really want to know is what variables to declare in order for this program to work. I don't want you to do that homework for me, but I'd like a bit of help,

I'll go ahead and post what I've already done, but it's literally nothing.


Thanks,
Toast

Is This A Good Question/Topic? 0
  • +

Replies To: Beginning java student traffic violations program

#2 stombo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 28-October 08

Re: Beginning java student traffic violations program

Posted 29 January 2009 - 07:55 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:
 Your Code Here 


Thank you for helping us helping you.

This post has been edited by stombo: 29 January 2009 - 07:56 PM

Was This Post Helpful? 0
  • +
  • -

#3 Toast_Jones  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 29-January 09

Re: Beginning java student traffic violations program

Posted 29 January 2009 - 08:05 PM

View Poststombo, on 29 Jan, 2009 - 06:55 PM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:
 Your Code Here 


Thank you for helping us helping you.



Well, I've done literally nothing at all... I always declare my variables first, and this is the first problem I've really been confused on. I'm pretty good at using the switch and if, else statements, which is what I'm supposed to be using in this chapter... and it's not like I can ask a teacher.... It's an online course. I would appreciate help but I understand if you don't as I haven't done much.






 

class Ch4P6
{
	public static void main(String args[])
	{			

 


This post has been edited by Toast_Jones: 29 January 2009 - 08:07 PM

Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Beginning java student traffic violations program

Posted 29 January 2009 - 08:15 PM

View PostToast_Jones, on 29 Jan, 2009 - 07:05 PM, said:

View Poststombo, on 29 Jan, 2009 - 06:55 PM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:
 Your Code Here 


Thank you for helping us helping you.



Well, I've done literally nothing at all... I always declare my variables first, and this is the first problem I've really been confused on. I'm pretty good at using the switch and if, else statements, which is what I'm supposed to be using in this chapter... and it's not like I can ask a teacher.... It's an online course. I would appreciate help but I understand if you don't as I haven't done much.






 

class Ch4P6
{
	public static void main(String args[])
	{			

 



No error up to that point... should work
Was This Post Helpful? 0
  • +
  • -

#5 Toast_Jones  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 29-January 09

Re: Beginning java student traffic violations program

Posted 29 January 2009 - 08:28 PM

View Postpbl, on 29 Jan, 2009 - 07:15 PM, said:

View PostToast_Jones, on 29 Jan, 2009 - 07:05 PM, said:

View Poststombo, on 29 Jan, 2009 - 06:55 PM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:
 Your Code Here 


Thank you for helping us helping you.



Well, I've done literally nothing at all... I always declare my variables first, and this is the first problem I've really been confused on. I'm pretty good at using the switch and if, else statements, which is what I'm supposed to be using in this chapter... and it's not like I can ask a teacher.... It's an online course. I would appreciate help but I understand if you don't as I haven't done much.






 

class Ch4P6
{
	public static void main(String args[])
	{			

 



No error up to that point... should work









Well... I know it would work... I guess what I'm trying to say is that I'm having trouble visualizing the variables I would need to declare for the rest of the program, you know, what they would parse into, what I need to represent... If I knew that, I think I would be on the right track.
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Beginning java student traffic violations program

Posted 29 January 2009 - 09:40 PM

We just won't do your homework unless you show some efforts...
so look at your assignment you need:
- the number of tickets
- tickets must contain speed over limit, amount of fine

- you need method to retreive total fines, total overlimit


class Ch4P6
{
	int nbTicket;			 // number of tickets in ticket array
	Ticket[] ticket;		 // array of tickets

	Ch4P6()  {								 // constructor
		ticket = new Ticket[100];		// make provision for a 100 tickets
	}

	// add a new ticket
	void addTicket(Ticket t) {
		ticket[nbTicket++] = t;
	}

	// cumulate all fines of all registered ticket
	double getTotalFine() {
		double total = 0;
		for(int i = 0; i < nbTicket; i++) {
		   total += ticket[i].fine;
		}
		return total;
	}
	public static void main(String args[])
	{			
	}

	class Ticket {
		double fine;
		int speedOver;
	}
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1