Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

is this information ok please let me know.. Nath class The Math class contains many usclul ricthodt that helo while doing calculations ce working weth

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed is this information ok please let me know..
Nath class The Math class contains many usclul ricthodt that helo while doing calculations ce working weth numbers in general. There are a few main categoeits of Math class methods Ixponent Netheds Trigonometrit Nethods Rounding Methods Rounding Methods Taker 4.3 foond ine Methods in the Math Class Name: Cosc10s5 Lab 4 part 1 10ng. P1eat, of doubte). For cuample, ase (4,4,5,0) nturns 5.9, ant win (3,2). renarna 2 . The abs method retarm the athelule valae of the nember (iat, long, float, or double). Random Methed Yos used the rasdoe () mathed in the peochlis chaper. This meliod grocrates a riedon You can use it ao write a simple espreuion to genenat nasbom manhers at any range. For enample. (int)(Hath,randon()*16)Retunsariodwnintegor50(int)(Rathravion()00)Recurnsarandominteger te remera, It is likely you won't use all of these during this course, but it it important to know what is available while working through problems. Character data type, and operations The character datatype is written with a character literal enclosed in SINGLE QUOTATIONS. This is different from a String that is written in double quotations. char letter = "A": char nunChar ="4 A char can hold any single character whether it be letters, numbers, symbols, or spaces and the enter character. A char takes up a byce of memory, it can store the values from 0 to 256 . Name: cosc1046 Lab 4 part 1 As you can see from the Dec column and the Char column, each character on your heyboard has a corresponding number. Since that only takes up the first 128 out of 256 , we atso hyve the extended ascii codes, which are less common: Unicode Java also uses Unicode, which was made to display a much larger variety of written texts in many diverse languages. Unicode works by taking two bytes preceded by a lo. This means that a Unicode character takes up 16 bits, and thus there is 1112064 posvible characters, which is vastly ereater than our basic char. Unicode values range from lu0000 to luFFFF. It uses Hexadecimal numbers, where each digit can be between 0 and 15. Since we cannot represent 10, 11, 12, 13, 14, and 15 as single digits, we instead use A,B,C,D,E, and F to represent them. Escape characters Escape characters are special characters that can be put into a char, characters like Backspace, Tab, and Linefeed (The enter key). You can put these values into a char, or inside of a string. Casting between char and numeric types It is possible to cast a chat into any numeric type, and vice vera. When an integer is cast inte a char only the lower 16 bits of data are used. If Wate a hes integer is written waing. profts ax char ch = (char)oxinoot1; fi. The loot 16 bits hes sede 0041 is Systen.out.printin(ch); (f ch is cheraster A If casting a flosting-point value using a double or float, it is first cast inte as int, and then finte a char. Name: Cosclo4 6 lab 4 part 1 When putting a Unicode value for a character into a byte data type, you do not need to explicitly cast it unless it is greater in value than what can fit into a byte. But the folloaing statenmest is incorroct, hecause the Unicode luffr 4 carnue fit into a bytr: byte th = "lufffe": To force this assignment, use eyplicit canting as followx: byte b = (byte) 'Iufffs: Chars can be compared, using =,=, and 1= Chars are compared using their Unicode value. Some other character class Methods Ex. Character isDigit('A') will return false Name: Cosc1046 Lab 4 part 1 Assignment Portion - hand in your work once completed "4.2 (Gromerry: grrat circle diapance) The grcal circle distance is the ditance betwees fwo points on the suaface of a sphcre. Let (x1,y1) and (x2,y2) be the goographical latitude and leegitude of two points. The great circle distance between the rwo points can be cograted asing the followieg formula; d=radiasarccos(sin(x1)sin(r2)+cos(x1)cov(x2)cos(y1x2)) Write a peogram that prompts the user to enter the latitude and longisode of two points ea the earth in degrees and divplyys its great circle distance. The average radius of the earth is 6.371.01km. Note you need to convert the degrecs into radians usieg the Hath, tolkadians method since the lava trigonometric mothods we radians. The latitede and lonpitede degrees in the formula are for nonth and weit. Ure negative to indicate wouth and cas degrees. Here is a sample run: Enter point 1 (latitude and lengitude) in degrees: 39.55116.25 ( Enter point 2 (latitude and lengitude) in degrees: 41.5.37,37 The distance betaeen the two points is 10691.79183231593km -4.8 (Fied the chandeier of an ASCU cosh) Write a prognasi that poceives a character and diyplays iti. ASCII code (an integer betaecn 9 and 127 . Here is a sanple num

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Find f.

Answered: 1 week ago