You are viewing our Forum Archives. To view or take place in current topics click here.
Anyone good at programming in netbeans?
Posted:

Anyone good at programming in netbeans?Posted:

OP
  • Blind Gifter
Status: Offline
Joined: Aug 06, 201211Year Member
Posts: 4,024
Reputation Power: 7011
Motto: Inconsistently Active oops
Motto: Inconsistently Active oops
Status: Offline
Joined: Aug 06, 201211Year Member
Posts: 4,024
Reputation Power: 7011
Motto: Inconsistently Active oops
Lab Assignment Number 4
CS1140
In this lab we will continue to make use of simple IO (input/output) and arithmetic
operators. You will also start using methods from the Math and the String class.
PART 1 Seconds all around
Have you ever wondered how many seconds there are over a given period of time?
Now you will finally be able to explore the world of seconds.
Your task is to write a program that will prompt the user for the number of weeks, days,
hours, minutes and seconds and your program will compute exactly how many seconds
there are over that period of time.
Create a Java application called Lab4_1.
Example run
Seconds Computation Program
How many WEEKS : 2
How many DAYS : 3
How many HOURS : 17
How many MINUTES : 42
How many SECONDS : 3
Total SECONDS during that time period is : 1532523
PART 2 More Seconds
Well that was so much fun that you have now decided that it would be interesting to be
able to do the reverse. In other words, if you are given a specified number of seconds
your program will compute the number of whole weeks, days, hours, minutes and
seconds that it breaks down into.
Your task is to write a program that will prompt the user for the number of seconds and
compute the appropriate weeks, days, hours, minutes and seconds that it would cover.
Create a Java application called Lab4_2.
Example run
Reverse Seconds Computation Program
What is the total number of SECONDS: 1532523
Number of whole WEEKS : 2
Number of whole DAYS : 3
Number of whole HOURS : 17
Number of whole MINUTES : 42
Number of SECONDS : 3
Note: Make sure that your outputs line up use printf
PART 3 Great Circle Distance
When dealing with distances on a globe of the earth, we refer to the shortest path
between any two points (as the crow flies) as the great circle distance. We can
compute this distance by solving the following formulas:
RADIUS = the radius of the earth = 6391.2 km declare as a constant
lat1 = the latitude of the first place user input
long1 = the longitude of the first place user input
lat2 = the latitude of the second place user input
long2 = the longitude of the second place user input
lat1_rad = lat1 converted to radians
long1_rad = long1 converted to radians
lat2_rad = lat2 converted to radians
long2_rad = long2 converted to radians
x1 = sin(lat1_rad)
z1 = cos(lat1_rad)
x2 = sin(lat2_rad)
z2 = cos(lat2_rad)
x3 = cos(long2_rad long1_rad)
a = (x1x2) + (z1 z2 x3)
distance = RADIUS cos -1
( a )
When the user enters latitudes it should be in degrees with negative numbers
representing South latitudes. Similarly, the longitudes should be degrees with negative
numbers representing West longitudes. Don`t worry, the GCC program will provide the
correct positive and negative values.
Print out the computed distance as an integer value rounded up. Use the approach
we discussed in class (hint: add half and cast). The Math functions you will need are:
Math.toRadians, Math.sin, Math.cos, Math.acos
Create a Java application called Lab4_3 that will execute as follows:
Example run
Great Circle Distance Program
Start Location
Enter latitude : 55.179722
Enter Longitude : -118.884999
End Location
Enter latitude : 51.4775
Enter Longitude : -0.461388
Computed Distance : 6890 Km
The website listed below is called the Great Circle Mapper. It allows you to find the lat and long for any
airport in the world. You can then use these locations to find the distances and the shortest path between
these two points.
[ Register or Signin to view external links. ]

Use it to verify that your program is computing the correct results. Dont worry if your distances are not
identical to those given by GC Mapper; however, they should be reasonably close.
Some example locations include:
YQU - Grande Prairie airport
YEG - Edmonton International airport
LHR - London Heathrow Airport
JFk - John F Kennedy International airport, New York
Note: Ive used an Earth radius which is about 20 Km larger than the accepted mean earth radius (earth
is not perfectly spherical). The modification in radius gives results which are closer to those computed by
GC Mapper (which uses a different algorithm for its computations).
PART 4 Amateur spy
Create a Java application called Lab4_4 that will let you decrypt an encoded message
stored in a file called: SecretMsg.txt
Display to the console window the following items which you will extract from the
message file. Please include a blank between each of the items below:
Extract the 4th word on the 1st line.
Extract and combine the first letters of the 2nd, 3rd, and 4th words of the 2nd line
(change them to upper case).
Extract and concatenate the 2nd word in the 3rd line with the 8th to 11th
characters from the 4th line of the file
Extract the first 4 characters of the 7th word in the 5th line.
The length of the 9th word on the 5th line.
The 4th and 5th characters of the 10th word on the 5th line
Concatenate the 3rd token in line 6 with the character : followed by the length of
the 7th line.
You will need to use a variety of String methods:
length(), charAt(), toUppercase(), substring().
Also you will need to use the following methods from the Scanner class:
next(), nextLine()
Hint :
when combining characters to form a string you will need a null string to start with.
String myword;
myword = ""; // myword initialized as a null string
myword = myword + 'a'; // myword concatenated with character 'a'
myword = myword + 'b'; // myword now points to the string "ab"


I am a tad bit lost, little bit of help would be nice.


Last edited by OP ; edited 1 time in total
#2. Posted:
-Deano
  • Spooky Poster
Status: Offline
Joined: Aug 19, 201013Year Member
Posts: 5,238
Reputation Power: 532
Status: Offline
Joined: Aug 19, 201013Year Member
Posts: 5,238
Reputation Power: 532
We cannot access the resource as we aren't users at your university/place of education.

You also haven't experience lined what you are struggling with or what you have attempted so I doubt many people would try to help.
#3. Posted:
CriticaI
  • TTG Addict
Status: Offline
Joined: Nov 05, 201310Year Member
Posts: 2,743
Reputation Power: 449
Status: Offline
Joined: Nov 05, 201310Year Member
Posts: 2,743
Reputation Power: 449
Do you have to use an IDE?
#4. Posted:
act1ve
  • New Member
Status: Offline
Joined: Jan 24, 20159Year Member
Posts: 30
Reputation Power: 2
Status: Offline
Joined: Jan 24, 20159Year Member
Posts: 30
Reputation Power: 2
In short, what can we help you with?
#5. Posted:
OP
  • Gold Gifter
Status: Offline
Joined: Aug 06, 201211Year Member
Posts: 4,024
Reputation Power: 7011
Motto: Inconsistently Active oops
Motto: Inconsistently Active oops
Status: Offline
Joined: Aug 06, 201211Year Member
Posts: 4,024
Reputation Power: 7011
Motto: Inconsistently Active oops
CriticaI wrote Do you have to use an IDE?

Yes, it is what weve been using all year
#6. Posted:
-Deano
  • Rated Awesome
Status: Offline
Joined: Aug 19, 201013Year Member
Posts: 5,238
Reputation Power: 532
Status: Offline
Joined: Aug 19, 201013Year Member
Posts: 5,238
Reputation Power: 532
Dezz wrote
CriticaI wrote Do you have to use an IDE?

Yes, it is what weve been using all year


What progress have you made so far? We're not here to do all of your work for you, we will help you if you are a little bit stuck though.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.