Answer:
#include <iostream>
using namespace std;
double DrivingCost(int drivenMiles,double milesPerGallon,double dollarsPerGallon)
{
double dollarsperMile=dollarsPerGallon/milesPerGallon;//calculating dollarsperMile.
return dollarsperMile*drivenMiles;//returning thr driving cost..
}
int main() {
double ans;
int miles;
cout<<"Enter miles"<<endl;
cin>>miles;
ans=DrivingCost(miles,20.0,3.1599);
cout<<ans<<endl;
return 0;
}
Output:-
Enter miles
10
1.57995
Enter miles
50
7.89975
Enter miles
100
15.7995
Explanation:
In the function first I have calculated the dollars per mile and after that I have returned the product of dollarspermile and driven miles.This will give the cost of the Driving.
The way in which Alexander can best improve his study area is that: D. he can put his computer on a desk and sit in a comfortable chair.
<h3>What is a laptop?</h3>
A laptop can be defined as a small, portable type of computer that is designed and developed by embedding both a mousepad and keyboard on it.
Also, it is usually light enough to be placed on an end user's lap while he or she is working.
In this scenario, the way in which Alexander can best improve his study area is that he can put his computer on a desk and sit in a comfortable chair.
Read more on a laptop here: brainly.com/question/26021194
#SPJ4
Answer:
// here is code in C++
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int n,no_open=0;
cout<<"enter the number of lockers:";
// read the number of lockers
cin>>n;
// initialize all lockers with 0, 0 for locked and 1 for open
int lock[n]={};
// toggle the locks
// in each pass toggle every ith lock
// if open close it and vice versa
for(int i=1;i<=n;i++)
{
for(int a=0;a<n;a++)
{
if((a+1)%i==0)
{
if(lock[a]==0)
lock[a]=1;
else if(lock[a]==1)
lock[a]=0;
}
}
}
cout<<"After last pass status of all locks:"<<endl;
// print the status of all locks
for(int x=0;x<n;x++)
{
if(lock[x]==0)
{
cout<<"lock "<<x+1<<" is close."<<endl;
}
else if(lock[x]==1)
{
cout<<"lock "<<x+1<<" is open."<<endl;
// count the open locks
no_open++;
}
}
// print the open locks
cout<<"total open locks are :"<<no_open<<endl;
return 0;
}
Explanation:
First read the number of lockers from user.Create an array of size n, and make all the locks closed.Then run a for loop to toggle locks.In pass i, toggle every ith lock.If lock is open then close it and vice versa.After the last pass print the status of each lock and print count of open locks.
Output:
enter the number of lockers:9
After last pass status of all locks:
lock 1 is open.
lock 2 is close.
lock 3 is close.
lock 4 is open.
lock 5 is close.
lock 6 is close.
lock 7 is close.
lock 8 is close.
lock 9 is open.
total open locks are :3
The program below is able to calculate the area of a circle inscribed in a Square.
<h3>What is a program?</h3>
A program is a set of instructions given to the computer with specific end results in mind.
<u>Sample program in Java
</u>// Java Program to find the area of
// an inscribed circle in a square.
import java.io.*;
class GFG {
static double PI = 3.14;
// Function to find area of an
// inscribed circle in a square.
static double areaOfInscribedCircle(float a)
{
return ( PI / 4 ) * a * a;
}
// Driver code
public static void main (String[] args)
{
float a = 8;
System.out.println("Area of an inscribed"
+ " circle: " + areaOfInscribedCircle(a));
}
}
Learn more about programs at :
brainly.com/question/1538272
#SPJ1