Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Overview Billionaire superhero Tony Stark has decided to give away his fortune to half the galaxy's inhabitants. When he snaps his fingers, Tony's powerful A.I.
Overview Billionaire superhero Tony Stark has decided to give away his fortune to half the galaxy's inhabitants. When he snaps his fingers, Tony's powerful A.I. assistant Friday will identify individuals who will each receive an equal share of Tony's total accumulated wealth. Friday is a computer, so it can't really pick half of all people at random... so instead, it will use a formula based on an individual's name to determine whether they gain a share of the money. You will program this formula and write an application to interact with it. Strings and Characters We know that a string is a sequence of zero or more characters. A computer doesn't really understand what a "character" is - it deals only with numbers, so when we see the character 'A' in our program, the computer actually considers that character to be a specific integer. Using a rule for assigning integers to each printable character called an encoding, a computer can then be programmed to work with strings by pretending that it's working with integers (You should note that uppercase and lowercase letters are different printable characters, and are given different values in an encoding.) The most common encoding in computers is called UTF-8, which is derived from an older encoding called ASCII. Every printable (and some unprintable) English letter, digit, or symbol was given a different number with the ASCII encoding system (example: A is number 65); UTF-8 takes those same values and expands them to include millions of other symbols used in non-English languages. The next time you write a text to a friend or a URL in your browser, take a moment to appreciate that all you're really doing is recording a bunch of integers Java uses a related format called UTF-16 for its strings and characters. Given a char variable, we can convert that char to the its integer value in UTF-16 by casting it to an int: char a X' int value (int)a
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started