An attribute of a website that will indicate a more reliable source of information is when the site ends in ".edu". It is a top-level domain for education. It would mean that this particular site is linked to universities, colleges or other educational sites thus it gives more information that is real and factual.
The programmer solves the problems of a user by expressing an algorithm in a programming language to make a program that can run on a computer.
Answer:
// here is code in java.
import java.util.*;
// class definition
class Main
{
// method that return total fare
public static double fare(double dis)
{
// calculate the total fare
double tot_fare=(4+((dis*1000)/140)*0.25);
return the fare
return tot_fare;
}
//driver method
public static void main (String[] args) throws java.lang.Exception
{
try{
// scanner object to read input string
Scanner s=new Scanner(System.in);
// variable
double dis;
System.out.print("please enter the distance in KM: ");
//read the number
dis=s.nextDouble();
// call the function with "dis" parameter
double ride_fare=fare(dis);
// print the total fare
System.out.println("total fare is: "+ride_fare);
}catch(Exception ex){
return;}
}
}
Explanation:
Read the distance from user with the help of scanner class.Call the function with parameter "dis".Here it will calculate the total fare as (4+((dis*1000)/140)*0.25). Here base fare is $4 and $0.25 for every 140 meter.Then function will return the total fare.
Output:
please enter the distance in KM: 7
total fare is: 16.5
Answer:
Written in Java
public static void printArray(int myarr[], String s){
for(int i = 0; i<myarr.length;i++){
System.out.print(myarr[i]+s);
}
}
Explanation:
This defines the static method alongside the array and the string variable
public static void printArray(int myarr[], String s){
The following iteration iterates through the elements of the array
for(int i = 0; i<myarr.length;i++){
This line prints each element of the array followed by the string literal
System.out.print(myarr[i]+s);
}
}
The method can be called from main using:
<em>printArray(myarr,s);</em>
Where myarr and s are local variables of the main