1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Firlakuza [10]
3 years ago
11

Trace the evaluation of the following expressions, and give their resulting values. Make sure to give a value of the appropriate

type (such as including a .0 at the end of a double or quotes around a String).
4 + 1 + 9 + "." + (-3 + 10) + 11 / 3
8 + 6 * -2 + 4 + "0" + (2 + 5)
1 + 1 + "8 - 2" + (8 - 2) + 1 + 1
5 + 2 + "(1 + 1)" + 4 + 2 * 3
"1" + 2 + 3 + "4" + 5 * 6 + "7" + (8 + 9)
Computers and Technology
1 answer:
Masja [62]3 years ago
7 0

Answer:

(a)\ 14"."43

(b)\ 0"0"7

(c)\ 2"8 - 2"611

(d)\ 7"(1 + 1)"46

(e)\ "1"23"4"30"7"17

Explanation:

Required

Evaluate each expression

The simple rules to follow are:

(1) All expressions in bracket will be evaluated based on its data type

(2) Divisions will return only integer values

(3) Integers immediately after string values will be concatenated (not added)

So, the results are as follows:

(a)\ 4 + 1 + 9 + "." + (-3 + 10) + 11 / 3

Evaluate till a string is encountered

4 + 1 + 9 = 14

Followed by "."

Then:

(-3 + 10)   = 7

11/ 3 = 3

"." + (-3 + 10) + 11/3 = "."73 -- because expressions after string operations are concatenated.

So, we have:

4 + 1 + 9 + "." + (-3 + 10) + 11 / 3 = 14"."43

(b)\ 8 + 6 * -2 + 4 + "0" + (2 + 5)

Evaluate till a string is encountered

8 + 6 * -2 + 4 =0

"0" + (2 + 5) ="0"7

So, we have:

8 + 6 * -2 + 4 + "0" + (2 + 5) = 0"0"7

(c)\ 1 + 1 + "8 - 2" + (8 - 2) + 1 + 1

Evaluate till a string is encountered

1 + 1 = 2

"8 - 2" + (8 - 2) + 1 + 1 = "8 - 2"611

So, we have:

1 + 1 + "8 - 2" + (8 - 2) + 1 + 1 = 2"8 - 2"611

(d)\ 5 + 2 + "(1 + 1)" + 4 + 2 * 3

Evaluate till a string is encountered

5 + 2 =7

"(1 + 1)" + 4 + 2 * 3 = "(1 + 1)"46 --- multiply 2 and 3, then concatenate

So, we have:

5 + 2 + "(1 + 1)" + 4 + 2 * 3= 7"(1 + 1)"46

(e)\ "1" + 2 + 3 + "4" + 5 * 6 + "7" + (8 + 9)

Since a string starts the expression, the whole expression will be concatenated except the multiplication and the expressions in bracket.

So, we have:

"1" + 2 + 3 + "4" + 5 * 6 + "7" + (8 + 9) = "1"23"4"30"7"17

You might be interested in
An authenticated user can add up to how many computer accounts to the domain, by default
Brums [2.3K]
By default, 10 computers can be joined to the domain by both users and administrators. As long as a user is authenticated against the Active Directory, he or she can add up to 10 computers to the domain.
While this one posses as an advantage for smaller companies, it is not a desirable feature for bigger companies since they have to control more tightly who can add machines to their domain.
7 0
3 years ago
Writing a function that implements a loop to collect a set amount of data. The function should use the serial object, the record
Assoli18 [71]
You can still go on a date with you if I get a text from my friend that is in a relationship and you don’t know why
4 0
3 years ago
Write a program that prompts the user to enter a string (may contain spaces) and displays its last character. Enter s string: Pr
STALIN [3.7K]

Answer:

<em>The programming language in Python is as follows:-</em>

#Prompt user for input string

userinput = input("Enter a string: ")

#Print the last character of the input

print("The last character is "+userinput[-1])

#End of Program

Explanation:

This line is a comment

#Prompt user for input string

This line prompts user for input

userinput = input("Enter a string: ")

This line is also a comment

#Print the last character of the input

This next line prints the last character of the input string; the last character is defined by the index -1

print("The last character is "+userinput[-1])

3 0
2 years ago
Friday Night Funkin Fans, does this count as a leak if I share it?
Aliun [14]
Hmm no I don’t think so
7 0
2 years ago
Read 2 more answers
How many times is the body of the loop executed?
Flura [38]

Answer:

The loop will run 5 times.

3 0
2 years ago
Other questions:
  • Classify the given items as belonging to the public domain or protected by copyright law.
    6·2 answers
  • To arrange data in alphabetical order quickly, you can _____ the data.
    7·2 answers
  • Assume you're running a query on your orders in the past year. You want to see how many orders were placed after May. What type
    5·1 answer
  • Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr
    7·1 answer
  • I have an airsoft pistol and I needed to take it apart to repair it and I lost some screws that were tiny and I dont know what t
    14·1 answer
  • Which of the following are valid calls to Math.max? 1. Math.max(1,4) 2. Math.max(2.3, 5) 3. Math.max(1, 3, 5, 7) 4. Math.max(-1.
    9·1 answer
  • WILL GIVE BRAINLIST IF ANSWER IS RIGHT AND YOU TELL ME HOW YOU GOT YOUR ANSWER (dont copy and past from a site)
    10·2 answers
  • Can you move it like this? I can shake it like that
    6·1 answer
  • Can someone pls do a toradora,Mha or princess jellyfish rp I'm open for anyother rp's
    11·2 answers
  • 7.2.4 Area of Triangle HELP PLEASE!! (JAVA SCRIPT) I WILL WAIT FOR THE SOLUTION.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!