1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mars2501 [29]
3 years ago
14

Write a program which will enter information relating to a speeding violation and then compute the amount of the speeding ticket

. The program will need to enter the posted speed limit, actual speed the car was going, and whether or not the car was in a school zone and the date of the violation. Additionally, you will collect information about the driver (see output for specifics). The way speeding tickets are computed differs from city to city. For this assignment, we will use these rules, which need to be applied in this order:
Computers and Technology
1 answer:
Nonamiya [84]3 years ago
3 0

Answer:

In Java:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 float speedlimit, actualspeed;

 String ddate;

 int schoolzone;

 System.out.print("Speed Limit: ");

 speedlimit = input.nextFloat();

 System.out.print("Actual Speed: ");

 actualspeed = input.nextFloat();

 System.out.print("Date: ");

 ddate = input.nextLine();

 System.out.print("School Zone (1-Yes): ");

 schoolzone = input.nextInt();

 float ticket = 75;

 ticket += 6 * (actualspeed - speedlimit);

 

 if(actualspeed - speedlimit > 30){

     ticket+=160;

 }

 if(schoolzone == 1){

     ticket*=2;

 }  

 System.out.print("Date: "+ddate);

 System.out.print("Speed Limit: "+speedlimit);

 System.out.print("Actual Speed: "+actualspeed);

 System.out.print("Ticket: "+ticket);

}

}

Explanation:

See attachment for complete program requirements

This declares speedlimit and actualspeed as floats

float speedlimit, actualspeed;

This declares ddate as string

 String ddate;

This declares schoolzone as integer

 int schoolzone;

This prompts the user for speed limit

 System.out.print("Speed Limit: ");

This gets the speed limit

 speedlimit = input.nextFloat();

This prompts the user for actual speed

 System.out.print("Actual Speed: ");

This gets the actual speed

 actualspeed = input.nextFloat();

This prompts the user for date

 System.out.print("Date: ");

This gets the date

 ddate = input.nextLine();

This prompts the user for school zone (1 means Yes, other inputs means No)

 System.out.print("School Zone (1-Yes): ");

This gets the input for schoolzone

schoolzone = input.nextInt();

This initializes ticket to $75

 float ticket = 75;

This calculates the additional cost based on difference between speed limits and the actual speed

 ticket += 6 * (actualspeed - speedlimit);

If the difference between the speeds is greater than 30, this adds 160 to the ticket  

<em>  if(actualspeed - speedlimit > 30){</em>

<em>      ticket+=160;</em>

<em>  }</em>

If it is in a school zone, this doubles the ticket

<em>  if(schoolzone == 1){</em>

<em>      ticket*=2;</em>

<em>  }  </em>

The following print the ticket information

<em>  System.out.print("Date: "+ddate);</em>

<em>  System.out.print("Speed Limit: "+speedlimit);</em>

<em>  System.out.print("Actual Speed: "+actualspeed);</em>

<em>  System.out.print("Ticket: "+ticket);</em>

<em />

You might be interested in
Assume the existence of a Building class with a constructor that accepts two parameters: a reference to an Address object repres
kolbaska11 [484]

Answer:

public ApartmentBuilding (Address addr, int sqFoo, int totUn) {

  super(addr, sqFoo);

  this. totalUnits = totUn;

}

Explanation:

To pass up parameters from a subclass constructor to a superclass constructor you just need to define a parameter name in the subclass constructor (in this case addr and sqFoo, but it can be anything you like) and then use the keyword super.

The keyword super acts exactly the same as the constructor of the superclass, however that may be defined.

And for the rest of the parameters (E.G. the ones of the sub class) you just treat them as a regular constructor.

8 0
3 years ago
If a disk drive has 8 surfaces and there are 1024 tracks per surface with 256 sectors per track and 512 bytes/sector. What is th
Elza [17]

Answer:

The capacity of the drive in Gigabytes equals 1.0737 Gbs

Explanation:

Given there are 1024 tracks per surface.

Number of surfaces = 8

Hence number of tracks in 8 surfaces equals 1024\times 8=8192 tracks

Now it is given that there are 256 sectors per track thus the number of sectors in 8192 tracks equals 8192\times 256=2097152 sectors

Now it is given that there are 512 bytes per sector thus the number of bytes in 2097152  equals 2097152\times 512=1073741824 bytes

Converting to gigabytes the capacity of the drive in gigabytes equals 1.0737Gbs

5 0
3 years ago
Which of the following correctly defines a procedure in computer programming? Choose all the apply.
Kazeer [188]

Explanation:

A code block programmers can reuse multiple times

3 0
4 years ago
Read 2 more answers
In round-robin scheduling,a) the time quantum should be larger than the context switch time. b) the time quantum should be as sm
pickupchik [31]

Answer: d. the time quantum should be as small as possible.

Explanation: Round robin is a CPU scheduling algorithm. If the time quantum is extremely small, number of context switches is very high, round robin scheduling will be same as processor sharing algorithm. Then the algorithm is good. Very large time quantum will make response time of processes too much which may not be tolerated in interactive environment.

3 0
3 years ago
When reading words using a Scanner object's next method, _________. a. any characters at the beginning of the input that are con
zavuch27 [327]

Answer:

The answer is "Option d"

Explanation:

The scanner method is the full token of the process, that finds and returns. It is token, which is followed by both the inputs meeting and the guideline template. This method can block, even though the former instance of hasNext() is true while waiting for input, and wrong choices can be described as follows:

  • In option a, It is incorrect because the character at the beginning can't be considered.
  • In option b, It is wrong because the characters are known as the word in which blank space not a part of the word.
  • In option c, It is wrong because in this input before the call is not the method.
3 0
3 years ago
Other questions:
  • In this project, you’ll create a security infrastructure design document for a fictional organization. The security services and
    5·1 answer
  • Many computer users and some operating systems call subdirectories ____.
    10·1 answer
  • What are three reasons teens might start drinking alcohol??
    7·2 answers
  • Which of the following technologies allows you to decouple the physical storage hardware from the storage requirements of the ap
    6·1 answer
  • You are planning the requirements for a site tracking and reporting system for your company Web site. Which of the following inf
    10·1 answer
  • What is technology??
    12·1 answer
  • You are the network administrator for a city library. Throughout the library, there are several groups of computers that provide
    12·1 answer
  • Collaboration, listening, and negotiating are considered __________ skills.
    11·1 answer
  • Although plants and ainamals are both living things___
    13·1 answer
  • If you aren’t familiar with the idea of a leap year, read “Why Is There a Leap Day?” before continuing with the lab.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!