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
pshichka [43]
4 years ago
9

Write a function DrivingCost with parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to

drive those miles. All items are of type float. Ex: If the function is called with 50 20.0 3.1599, the function returns 7.89975. Define that function in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both floats). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three times. Ex: If the input is 20.0 3.1599, the output is: 1.57995 7.89975 63.198 Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a b)/3.0 is the same as a/3.0 b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. In the DrivingCost function, use the variables in the following order to calculate the cost: drivenMiles, milesPerGallon, dollarsPerGallon.
Computers and Technology
1 answer:
solniwko [45]4 years ago
8 0

Answer:

See explaination

Explanation:

Function DrivingCost(float drivenMiles, float milesPerGallon, float dollarsPerGallon) returns float cost

float dollarsPerMile

//calculating dollars per mile

dollarsPerMile=dollarsPerGallon/milesPerGallon

//calculating cost

cost=dollarsPerMile*drivenMiles

Function Main() returns nothing

//declaring variables

float miles_per_gallon

float dollars_per_gallon

//reading input values

miles_per_gallon = Get next input

dollars_per_gallon = Get next input

//displaying cost for 10 miles

Put DrivingCost(10,miles_per_gallon,dollars_per_gallon) to output

//printing a blank space

Put " " to output

//displaying cost for 50 miles

Put DrivingCost(50,miles_per_gallon,dollars_per_gallon) to output

Put " " to output

//displaying cost for 400 miles

Put DrivingCost(400,miles_per_gallon,dollars_per_gallon) to output

You might be interested in
Write Java code that creates an array of n integers myArray, by taking n integers from the user with duplications, and do the fo
skad [1K]

Answer:

this should be what you need

Explanation:

import java.util.*;

public class ABC{

 public static void main(String[] args) {

   int n;

   //create scanner object

   Scanner sc = new Scanner(System.in);

   //ask for size of array

   System.out.print("Enter the size of array (n): ");

   //read the input

   n = sc.nextInt();

   //create an array of n length

   int [] myArray = new int[n];

   //ask user for array elements

   System.out.printf("Enter %d integers: ", n);

   //read array elements

   for(int i =0 ;i <5; i++)

     myArray[i] = sc.nextInt();

   

   //print the elements if myArray

   System.out.print("1 - The values of myArray are: [");

   for(int i =0 ; i < n; i++){

     System.out.print(myArray[i]);

     if(i < n-1)

       System.out.print(", ");

   }

   System.out.print("]\n");

   //calculate mean and sum of myArray elements

   int sum = 0;

   double mean = 0;

   for(int i = 0; i < n; i++)

     sum += myArray[i];

   

   mean = (sum*1.0)/n;

   //print the sum and mean of myArray

   System.out.printf("2 - The sum is: %d. The mean is: %.1f\n", sum, mean);

     

   //create an arraylist

   ArrayList<Integer> myArrayList = new ArrayList<Integer>();

   //copy the value of myArray to an arraylist without duplicates

   for(int i = 0; i < n; i++){

     if(!myArrayList.contains(myArray[i]))

       myArrayList.add(myArray[i]);

   }

   sum = 0; mean = 0;

   //display the values of myArrayList

   System.out.print("3 - The values of myArrayList are: [");

   for(int i =0 ; i < myArrayList.size(); i++){

     System.out.print(myArrayList.get(i));

     if(i < myArrayList.size()-1)

       System.out.print(", ");

   }

   System.out.print("]\n");

   //calculate sum and mean of myArrayList elements

   for(int i = 0; i < myArrayList.size(); i++)

     sum += myArrayList.get(i);

   mean = (sum*1.0)/myArrayList.size();

   //print the sum and mean of myArrayList

   System.out.printf("4 - The sum is: %d. The mean is: %.2f\n", sum, mean);

 }

}

3 0
3 years ago
Rows within a spreadsheet are identified by:
EleoNora [17]

Answer:

Option C: Numbers.

Explanation:

By default, rows within a spreadsheet are identified by Numbers i.e. 1,2,3,............

Total rows are 1048575 in one spreadsheet.

7 0
4 years ago
Assume the integer variable num has been assigned a valid value. What is the purpose of the following code segment?
Pie

Answer:

2

Explanation:

The num%4 operation returns the remainder, so only if num is not a multiple of 4, this value will be non-zero (it will be 1, 2 or 3).

7 0
3 years ago
The advancement of technology in our daily lives has changed how we interact with the world.
matrenka [14]
I agree. i think there’s less communication, more anger, mental issues.
5 0
3 years ago
A web application that is designed as a single piece of software with multiple features that are fully integrated into the main
Nookie1986 [14]

Answer:

c. Service oriented architecture (SOA)

Explanation:

In a service oriented architecture (SOA), a component of an application provides services to other components of the application or other applications majorly via a communications protocol over a network. In other words, SOA is a programming or software development technique in which services communicate with each other across different platforms.  

One key principle of SOA is to design an application (which in itself is a piece of software with multiple features) that is independent of any product, service, vendor or technology but can be integrated into other applications. SOA makes use of loose coupling -  a technique in which a client service remains independent of another service that requires it.

In contrast, a monolithic architecture aims at developing a software that is self-contained, independent and not to be integrated into other applications.

On another hand, Software as a service (SaaS), though a bit similar to SOA, is a model in which an application is made available to customers basically through a network. Users basically access the application via a browser.

Therefore, the best option is

C. Service oriented architecture.

3 0
3 years ago
Other questions:
  • A user is trying to delete a file located on an NTFS volume on his Windows 8 computer but is unable to do so. Why is this?
    6·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    9·1 answer
  • Which of these items will least likely increase pressure in the evaporative emission control system?
    9·1 answer
  • Which of the following creates an array of 25 components of the type int?
    6·1 answer
  • Which windows 10 edition can a device with windows 8 or 8.1 pro upgrade to
    5·1 answer
  • A general rule for printing is to use _____ fonts for headlines and serif fonts for body text
    6·1 answer
  • Helllllllllppppppppppp
    9·1 answer
  • Read the following scenario:
    10·2 answers
  • 9.3 Code Practice
    13·2 answers
  • Select the one that uses the heading tag correctly. <br><br>a. <br><br><br>b. <br><br>c. <br><br>d.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!