Tricia Lemay

Greenhorn
+ Follow
since Sep 16, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tricia Lemay

Hi guys,

Just wanted to pass on an update. I stepped through the problem incrementally. I was using yearsDepreciated and changing it - then trying to compare it. When yearsDepreciated got halfway through it equalled out. I created a local variable for the numerator and maintaind the integrity of yearsDepreciated. It may not be "correct" or pretty..... but I get the output I want.

I think I need the last piece of code discussed. First I need to chart the years (1, 2, 3, 4, 5) and then I need to decrement in the numerator of the formula (n, n-1, n-2 etc). I don't know any other way to do that.?

I really want to thank all of you on the forum. Often I will see posts where people want the work done for them. I've learned more from being pointed in the right direction and continuing on from there than someone sitting down and doing my work for me. The explanations I've received here have enabled me to acheive a higher understanding of the language (as little that understanding is!)Thanx for being out there!
15 years ago
Thanx for the input guys I'm gonna keep working on it and try what you suggest. I know it's something stupid that I am overlooking because I did have the count working correctly at one point. Fiddling too much with it I think!
15 years ago
This is the output:

Please enter the original value: 200000
What is the final value of the product? 50000
What is the number of years you wish to depreciate the product? 5

Years Depreciation
_________________________
1 50000.0
2 40000.0
3 30000.0

Do you want to continue? y/n
n

15 years ago
Thanx Jimmy! The "my" variables were prsvate variables I had defined. I switched them out and compiled (along with a closing brace). I got most of the output as expected. But it is double counting "n" somewhere because it only runs 1, 2, 3 and stops. I tried other numbers of years and it basically prints half the number of responses. Here's more code... thanx, you've helped a lot already and I really appreciate it.


[ December 02, 2004: Message edited by: Tricia Lemay ]
15 years ago
Hi everyone,

Working on a program to figure depreciation tonight. The following code is to print a chart. I go through the logic, and it seems to do what I want, but I'm not getting the output I expect.

Example output where the original cost is 200000, the final value is 50000 and I depreciate for 5 years.

Years Depreciation
_____________________________

1 50000
2 40000
3 30000
4 20000
5 10000

I think my problem may be with braces, but I've tried every combination to no avail. At one point, I was getting 1-5 and 0.00 for depreciation. I've made changes to resolve other issues and now get nothing but the heading.
Thanx in advance for any suggestions!


[ December 01, 2004: Message edited by: Tricia Lemay ]
15 years ago
Got it working, just needed to change around the calculates and the gets!

Thanx again!
15 years ago
It's still not calculating right, but most importantly I am getting data! Now, I'll go back and see why I'm not getting what I want.

Thanks for your help.
15 years ago
Hi guys. Been messing with this for days. I'm not receiving any compile errors, but only generating 0's for output. I'm missing something but can't put a finger on it. Any suggestions on where to begin looking for a solution?

code

public class TimeInterval
{

private int mySecondTime;
private int myFirstTime;

public TimeInterval(int time1, int time2)
{

int myFirstTime = time1;
int mySecondTime = time2;
}

public int calculateHours()
{
int firstMin=myFirstTime/100*60+myFirstTime%100;
int secondMin = mySecondTime/100*60+mySecondTime%100;
int diff = secondMin-firstMin;
return diff/60;
}

int calculateMinutes()
{
int firstMin=myFirstTime/100*60+myFirstTime%100;
int secondMin = mySecondTime/100*60+mySecondTime%100;
int diff = secondMin-firstMin;
return diff%60;
}

public int getFirstTime( )
{
return myFirstTime;
}

public int getSecondTime( )
{
return mySecondTime;
}

public String toString( )
{
String message;
return message = getFirstTime() + " hours " + getSecondTime() + " minutes";

}


}

Test


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class TimeIntervalTest {
public static void main(String[] args) throws IOException
{

BufferedReader console = new BufferedReader( new InputStreamReader(System.in));
System.out.print("Please enter the first time: ");
String input = console.readLine();
int time1 = Integer.parseInt(input); // convert string to int

console = new BufferedReader( new InputStreamReader(System.in));
System.out.print("Please enter the second time: ");
input = console.readLine();
int time2 = Integer.parseInt(input); // convert string to int

TimeInterval interval = new TimeInterval(time1,time2);

interval.calculateHours();
interval.calculateMinutes();

System.out.println (interval.toString());

System.exit(0);
}
}

Thanx for taking a look!
[ October 26, 2004: Message edited by: Tricia Lemay ]
15 years ago
Thanx Svend,

Yes, it's helped. I don't like "value" either. Maybe I am just making the question harder than it is. (I think it is a badly worded question in the first place.

T/F

An instance field is a variable defined in a class for which every object of the class has its own value.

Well... I got a 50/50 chance on it don't I!

15 years ago
Seems like a whole "nother" language! My head hurts! So does every object have it's own value?
15 years ago
Just checking to be sure I'm understanding correctly.

An instance field is a variable defined in a class. This is true.

This instance field is present in every object of the class.

The object is merely a reference to the value that is stored in the instance variable. The object is not a value in itself but just a state.

Is this correct? Or should I work on this somemore?
15 years ago
OK, I am reading the first chapter of the book, thanx for the site, I think I will be needing the rest of the chapters! I've also gone back and read everything written on the topic. I am also very grateful today that I am an IS major and not a CS major because I would be in a lot of trouble! I have total respect for all of you and truely appreciate your time.

I think I am beginning to understand the concepts but it is slow going. The word "data" is actually what is hanging me up.

The question I am actually trying to answer is:

What does the following code do?

Point p1 = new Point(2,14);

I have narrowed the answer to either

Constructs a Point object at location(2,14) and stores the data in p1.
or
Constructs a Point object at location(2,14) and stores the reference in p1.

Before I posted, my answer was the first choice. Now I'm not so sure. I'll go read that chapter!

Thanx again for your help,

Tricia
16 years ago
So, if I understand this correctly, the values 2 and 14 for the x-y coordinates are not considered data. They are just references to a point at that location?
16 years ago
Hi, I'm really new to Java and object based programming so forgive me if I sound clueless here because I probably am! When I am constructing a point using specific parameters, for example, Point p1 = new Point (2,14); am I storing data in p1 or am i just creating a reference to p1 as I would with ()? Thanx for any assistance.
16 years ago