Introduction to Computers -1 st exam- 授課教授:李錫智
1. Given 12 bits, (a).How many different distinct combinations can we get from these bits? Ans: 2 12 = 4096 (b). What is the largest unsigned integer we can get from these bits? Please write it out in decimal representation. Ans: = 4095
1.Given 12 bits, (c). What is the smallest unsigned integer we can get from these bits? Please write it out in decimal representation. Ans: 0 (d). John wrote a book consisting of 2097 pages. Each page contains 500 characters. Suppose each character is represented by a byte. John wants to store his book in a 1 MB memory. Is the memory big enough for the book? Why or why not? Ans: 1MB = 2 20 Bytes = Bytes 2097*500*1 = < 1MB, so it’s enough.
1-(e). Mary wants to represent any integer between -16 and 15. How many bits does Mary need to use? Ans: -16~15 There have 32 integers, so it just need 5 bits to repersent them.
2. What does Var represent in each case: (a). Var = “ is the sum”; (b). Var = 10 + “ is the sum” + 24; (c). Var = “The sum is “ ; (d). Var = “The sum is “ + ( ); (e). Var = “” “ is the sum”; Ans: (a). 34 is the sum ( b). 10 is the sum24 (c). The sum is 1024 (d). The sum is 34 (e) is the sum
3. Suppose the speed of instruction execution is proportional to the clock rate of the CPU. If a program is run by a 1.5GHz CPU in 30 minutes, how soon will it be run by a 2.5GHz CPU? Ans:, X=18
4. What does the following web page look like on the screen? How Great is HTML Hello! EE-NSYSU Freshmen 200 Senior 20 How wonderful the department is!
Ans:
5. Write a web page to show the following table on the screen. Ans: Tuesday Chinese Physics TuesdayChinese Physics
6. Create a web page that can be used to compute a student’s overall average for a course. Your page should prompt the user to enter his or her homework score, test 1 score, test 2 score, test 3 score, and test 4 score, and compute and show the overall average on the screen as shown below (Assume the grade weightings for homework is 10%, test 1 20%, test 2 20%, test 3 25%, and test 4 25%.) Homework score: 80 Test 1 score: 40 Test 2 score: 60 Test 3 score: 80 Test 4 score: 100 Overall average: 73
Ans: temp=prompt("Enter the homework score: ", ""); hw=parseFloat(temp); temp=prompt("Enter the test1 score: ", ""); t1=parseFloat(temp); temp=prompt("Enter the test2 socre: ", ""); t2=parseFloat(temp); temp=prompt("Enter the test3 score: ", ""); t3=parseFloat(temp); temp=prompt("Enter the test4 socre: ", ""); t4=parseFloat(temp);
avg=(hw*0.1)+(t1*0.2)+(t2*0.2)+(t3*0.25)+(t4*0.25); document.write("Homework score: "+hw+" "); document.write("Test 1 score: "+t1+" "); document.write("Test 2 score: "+t2+" "); document.write("Test 3 score: "+t3+" "); document.write("Test 4 score: "+t4+" "); document.write(" "); document.write("Overall average: "+avg);
7. What does the following web page look like on the screen (Suppose the user types in 12)? Compute Square Var = prompt(“Enter the input:”, “”); Var = parseFloat(Var); document.write(“ ”); document.write(Var + “*” + Var + “ = “ + Var*Var); document.write(“ ”);
Ans: