Some Questions - from old test papers 100 level

Ekk... I have a test tonight and am trying to make sense of all this:

Some questions that I'm not sure about are:

1. For each part (and each sub part) of this question assume:

int i = 8;

double d = 3.9;

char c = 'x' , k;

Show the value stored in the left hand side of the assignment statements below:

k = c;

k = 'c';

Write a boolean assignment statement that sets b to true when (and only when): c is not 'i' or 'o' or 'u'

2. Assume that calc is in a class that has a double data field cost, write the method so that it returns nothing, but instead stores the result in the data field.

3. Assume that calc is in a class which has double data fields called a and b. Write this method so that it takes no input, but returns the sum of the data fields multiplied by 10.

Some help (pref before tonight) would be very much appreciated.:confused:

ok.. np, these are what I think the answers might be?

1. For each part (and each sub part) of this question assume:

int i = 8;

double d = 3.9;

char c = 'x' , k;

Show the value stored in the left hand side of the assignment statements below:

k = c; --> I think this gives reference to the corresponding uni number for c?

so k = that number (what ever it might be?)

k = 'c'; --> here I think c is stored in k so k = c?

Write a boolean assignment statement that sets b to true when (and only when): c is not 'i' or 'o' or 'u' --> boolean b = true (c != 'i' || c != 'o' || c != 'u') Here I wasn't sure about using the || twice inside the expression??

2. Assume that calc is in a class that has a double data field cost, write the method so that it returns nothing, but instead stores the result in the data field.

Here I'm really unsure:

Assume: double cost;

public void calc(){ //void as it returns nothing?? is that right?

double cost // but how do I write this so it stores the result in the data field?

Any hints would be appreciated

3. Assume that calc is in a class which has double data fields called a and b. Write this method so that it takes no input, but returns the sum of the data fields multiplied by 10.

Assume:

double a;

double b;

public double calc() {

return 10*(a+b);

} // any pointers here if this is wrong would be appreciated

Thanks :)