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
A web application with an SQL server database is found to be compromised by an attacker. On examination, the email IDs of the da
Thepotemich [5.8K]

Answer:

This is what we call SQL Injection.

• SQL Injection is when an attacker compromises your database only if it is vulnerable.

• Vulnerability includes leaving an empty ""(value) or forgetting to close anything that could be attacked.

• Ways to prevent injection is to not use string concatenation.

(<em>ex.</em> "hello" + "world")

*  Use parameterized queries.

*   Immediately get rid of any unused code.

5 0
2 years ago
Explains why it is important to select the correct data when creating a chart
Liula [17]

Answer:

to be organized

Explanation:

<h2>because when you are organized to select the correct data, you won't confused </h2>
4 0
3 years ago
When you have to make a long-distance call, dialing an unfamiliar area code plus a seven-digit number, you are likely to have tr
Mashutka [201]

Answer:

c. short-term

Explanation:

According to a different source, these are the options that come with this question:

a. long-term

b. implicit

c. short-term

d. explicit

This best illustrates the limited capacity of short-term memory. Short-term memory is the most recent information that a person holds in his head. Usually, this corresponds to events that occurred in the last 30 seconds to the last few days. This type of memory stores recent events, as well as sensory data such as sounds.

3 0
3 years ago
A distribution of software that simplifies administration by identifying dependencies, automatically updating configuration file
emmasim [6.3K]

Answer:

Package

Explanation:

In a conventional kind of definition, a software package is basically several applications or code modules that work hand-in-hand to meet a range of goals and objectives. One of the most well-known examples is package like the Microsoft Office package, which consist of individual applications such as Excel, Word, Access and PowerPoint.

It can also be said to be numerous individual files or resources that are packed together as a software set which is meant to provides specific functionality as part of a larger system.

6 0
3 years ago
What enables image processing, speech recognition, and complex game play in Artificial Intelligence (AI)?
zysi [14]

Explanation:

Deep Learning enables image processing, speech recognition, and complex game play in Artificial Intelligence

3 0
3 years ago
Other questions:
  • Let K(x, y) denote the statement "x knows y" and D denote the domain of all people. Express the following English sentences as a
    9·1 answer
  • 6.67
    5·1 answer
  • (a) Write a SCHEME function (make-change n den) which outputs a list of change specifications. Namely, a call (make-change 11 (l
    8·1 answer
  • The tools that cyber criminals often use, including computer viruses, worms, trojan horses and spyware, are called __________. q
    5·1 answer
  • How to study program ?
    11·1 answer
  • To move to the beginning of the line with the keyboard, press the _______ key(s).
    6·1 answer
  • What does route print do?
    15·1 answer
  • Puter Science (IS)
    14·1 answer
  • I am writing a Python code to ask a user to enter students' information including name,
    10·1 answer
  • ​what is the difference between a normal mouse and trackball? What do you think. ​​​​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!