Answer:
Following are the step by step algorithms is explain below.
Explanation:
Following are the algorithm for searching shortest distances.
- Firstly, Initialize the array variable distance[] = {INF, INF, ….} as well as distance[s] = 0 in which the variable 's' is the beginning vertex
- Then, you have to develop a topological order of the following vertices.
- So, Do in the following for mostly vertex that is the variable 'u' in the topological order.
Do on the following for mostly contiguous vertex that is 'v' of 'u'
if (dist[v] > dist[u] + weight(u, v))
dist[v] = dist[u] + weight(u, v)
Answer:
The correct answer to this question is: "this program give an error".
int i = 7; //declare a variable(i) and assign value.
while (i>=2) //use loop and check condition.i greater then equal to 2.
{
System.out.print (i +""); //print value of i.
if ((i%3) == 0) //hold remainder
{
i +2; //error.
}
else
{
i/=2; //hold Quotient
}
}
Explanation:
In the above program, there is an error in the if block because it is not the correct way to declare. To use the variable from the correct output we use a variable like this.
Example
int i = 7;
//declare a variable(i) and assign value.
while (i>=2)
//use loop and check condition.i greater then equal to 2.
{
System.out.print (i +""); //print value of i.
if ((i%3) == 0) //hold remainder
{
i =i+2;
}
else
{
i/=2; //hold Quotient
}
}
Output: 732
Answer:
Well it makes life easier of course we don't need it to survive but it just makes stuff easier
Explanation:
Answer:
public static void printFeetInchShort(int numFeet, int numInches) {
System.out.println(numFeet+"\'"+ numInches+"\"");
}
Explanation:
To format the output properly, make use of the excape sequences (\' and \'') with string concatenation.
The complete code is given below:
public class StringLength {
public static void printFeetInchShort(int numFeet, int numInches) {
System.out.println(numFeet+"\'"+ numInches+"\"");
}
public static void main(String[] args) {
printFeetInchShort(5, 8);
System.out.println("");
}
}