1.The following code segment is to exchange the two images. What\'s wrong with i
ID: 3915337 • Letter: 1
Question
1.The following code segment is to exchange the two images. What's wrong with it? How to fix it?
document.getElementById('leftImage').src = document.getElementById('rightImage').src
document.getElementById('rightImage').src = document.getElementById('leftImage').src
2.
Write a function named timeConversion that
takes year as a parameter
converts it to the corresponding number of hours, and
return the hours
3.Define a function named randomNum, which takes two parameters, low and high, and generate a random number from the range low (inclusive) and high (exclusive). Display the generated number in an alert window.
Explanation / Answer
Ans 1.var temp = document.getElementById('leftimage').src; /*this is to store the image in temporary variable */
document.getElementById('leftimage').src = pic2; /* to store the pic2 in first pic */
document.getElementById('rightimage').src; = temp; /*to store the image of temp in second one*/
Ans2. void main(){
int year, hour;
printf("enter the year"); //to get the year value as input
scanf("%d", &year);
if(year%4 ==0) //check condition if it a leap year
{
hour= 366*24; //As leap consist of 366days
}
else
{
hour=365*24;
}
printf("hours are %d", hour); //print value of hours calculated
getch();
}
Ans 3.
?
import java.util.*;
import javax.swing.JOptionPane;
public class RandomNum
{
public static void main(String args[])
{
int low=10, high=100;
int rand = Math.random() * (+high - +low) + +low;
// Generating random doubles
System.out.println("Random variable is " + rand);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.