Question:
Ap Computer Science Help.?
2011-10-08 13:47:14 UTC
1) Given the following declarations, what result is stored in each of the listed assignment statement?
int iResult, num1 = 25, num2 = 40, num3 = 17, num4 = 5
double fResult, val1 = 17.0, val2 = 12.78
a) iResult = num1 / num4
b) fResult = num1 / num4
c) iResult = num3 / num4
d) fResult = num3 / num4
e) fResult = val1 / num4
f ) fResult = val1 / val2
g) iResult = num1 / num2
h) fResult = (double) num1 / num2
i ) fResult = num1 / (double) num2
j ) fResult = (double) (num1 / num2)
k) iResult = (int) (val1 / num4)
l ) fResult = (int) (val1 / num4)
m) fResult = (int) ((double) num1 / num2)
n) iResult = num3 % num2

2) What output is produced by the following code fragement?
String m1, m2, m3;
m1 = "Quest for the Holy Grail";
m2 = m1.toLowerCase();
m3 = m1 + " " + m2;
System.out.println (m3.replace( 'h', 'z' ));

3) Write a single statement that computes and prints the absolute value of total.

4) Assuming that a Random object called generator has been created, what is the range of the result of each of the following expressions?
a) generator.nextInt(20)
b) generator.nextInt(8) + 1
c) generator.nextInt(45) + 10
d) generator.nextInt(100) - 50

Any help would be greatly appreciated. Thanks in advanced
Four answers:
Flame
2011-10-08 14:10:37 UTC
1. its just math. Carelful though with doubles going to int's, and the % (divide and then keep Remainder)



2. toLowerCase does exactcly what it says, makes everything lowercase. then it wants you to put the two strings together with a space in the middle. then replace all the h's with z's



3. google absolute value java, i'm sure you'll find something. That should be an easy question. Print statement and inside of that, put the absolute value, then like 5 - 10 (would equal -5, but absoulte value will print out 5)



4. If i remember correctly, random number generators display numbers 0 to x-1 (x being the number in the () )

ex- (again if i'm remembering this right) A should print out 0-19 (20 differen't digits)
kaup
2016-10-23 11:54:32 UTC
properly, it quite relies upon on what you desire to flow to college for. besides the incontrovertible fact that, on a controversy scale i could ought to assert that AP Comp. Sci. is the toughest, then AP E.S., then AP Psychology. So getting an A and a 5 in AP CS probable seems greater helpful... i assume. AP laptop technology teaches you with reference to the programming language Java, so in case you have no thought what it extremely is approximately you probable do no longer desire to take it. except you desire to check quite, quite rapid. you apart from mght desire algebra skills in programming. AP Psychology is... AP Psychology and is extremely hardship-free for an AP classification. AP Environmental technology is like Environmental technology yet on steroids. Ish.conventional Environmental technology is extremely hardship-free so i assume it extremely is not any longer asserting plenty, besides the incontrovertible fact that it extremely is a technology classification. As for Honors physique shape, properly, i will inform you that AP classes seem greater helpful than Honors classification. however the class itself is like... human biology. Human physique structures etc.
2011-10-08 13:50:33 UTC
Are you kidding? Question 1 is just basic math for the most part. 2 is extremely basic string manipulation. And 3 is just random number generation. You want some help? Here's some help, for 1a, you need to know how to divide.
tom
2011-10-08 13:51:40 UTC
I could give you the answer but that would take all the fun out of it for you ap kid.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...