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
ira [324]
3 years ago
14

What will be the result of running the following code fragment? int year = 0; double rate = 5; double principal = 10000; double

interest = 0; while (year < 10) { interest = (principal * year * rate) / 100; System.out.println("Interest " + interest); }
Computers and Technology
1 answer:
NemiM [27]3 years ago
5 0

Answer:

This code fragment will run an infinite loop

Explanation:

This output: Interest 0.0 Will be displayed infinitely. The reason is because the variable year which is initially set to 0 is never updated and as such remains true because the condition is while(year<10). So at the first iteration the statement interest = (principal * year * rate) / 100; evaluates to 0 and this line of code System.out.println("Interest " + interest); prints Interest 0.0. At the next iteration the same evaluation and output takes place and on and on and on....... since the control variable is not changing.

You might be interested in
Renée’s job entails using a company laptop to constantly open other peoples’ workbooks, sorting the data, importing a new sheet
nevsk [136]

she should leave and go somewhere else for a mminute to cool and then come backa nd close tabs.

6 0
3 years ago
What is one way for an entrepreneur to decrease risk?
marysya [2.9K]

Answer

we can  decrease risk for an entrepreneur by creating a team of trusted advisors to rely on.

there are some points that we can take in mind know how  to position our company as a safe position.

revenue streams and additional technology, paving the way for future growth.

Entrepreneurs can use all these  unique strategies to decrease those risk

8 0
3 years ago
Write a program that reads the data from rawdata_2004.txt into a dictionary whose keys are country names and whose values are pe
san4es73 [151]

Answer:

import re

def country_capita():

   #opens file

   file=open("inputfile.txt", "r")

   dictionary=dict()

   #reads line by line

   for line in file.readlines():

       # substitutes for multiple space a single space

       line = re.sub(r"[\s]{2, }", ' ', line)

       list=[]

       #splits line on space

       list=line.split(" ")

       #put into dictionary

       dictionary[list[1]]=list[2]

#   get input

   while True:

       choice=input("Enter the country name or quit to exit: ")

       if choice=="quit":

           break

       elif choice in dictionary.keys():

           print(dictionary[choice])

       else:

           print("Invalid Country")

country_capita()

Explanation:

Using python to code this program. First we, (line 1) import the re module which offers us a set of functions that allows us to search a string for a match. ((line 2) Next we define a function country_capita() that will open rawdata_2004.txt, read the information within line by line and create a dictionary list. The we create a while loop with conditional statements that prompt the user to enter country names, print the corresponding values and stops when the user enters quit.

7 0
3 years ago
BlockPy: #38.2) While Input Use a while loop to repeatedly take input from the user and print whatever they type in. When the us
BARSIC [14]

Answer:

strr=input("please enter something: ")

while strr is not "":

   print(strr)

   strr=input("please enter something: ")

Explanation:

whenever the user will enter an empty string the loop will terminate

8 0
4 years ago
What is the value of the variable named result after the following code executes?
Makovka662 [10]

Answer:

The value of result is 20

Explanation:

Given

The above code segment

Required

The value of result

In the first line, we have:

X = 5; Y = 3; Z = 2

In the second, we have:

result = (X + Y)/Z * X

This implies that:

result = (5 + 3)/2 * 5

result = 8/2 * 5

result = 4 * 5

result = 20

3 0
3 years ago
Other questions:
  • Jack wants to store a large amount of data on his computer. He chooses to use a database for this purpose. What is a database? A
    8·1 answer
  • For each of the following six program fragments: a) Give an analysis of the running time (Big-Oh will do). b) Implement the code
    5·1 answer
  • It is not possible to use keywords to search for themes
    5·1 answer
  • Having network users login with a username and password is an example of:
    12·1 answer
  • How do you leave a conversation or group text on iphone (ios 10)? Help!!
    5·1 answer
  • Which bitwise operation has the same effect as multiplying a by 16?
    6·2 answers
  • Knowledge and experience help you
    11·1 answer
  • The processor of a computer communicates to the other parts of the computer through a code that consists of what?
    9·1 answer
  • Jack is part of the software quality assurance team in a company. Which activity should Jack perform as a part of software quali
    11·1 answer
  • What are the most common processes and procedures handled by data warehousing specialists? select all that apply.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!