answer.
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
Nataly_w [17]
1 year ago
15

A shop will give discount of 10% if the cost of purchased quantity is more than 1000. Ask user for quantity suppose, one unit wi

ll cost 100. Judge and print total cost for user.
Computers and Technology
1 answer:
UkoKoshka [18]1 year ago
4 0

Answer:

The program in Python is as follows:

qty = int(input("Quantity: "))

price = 100 * qty

if qty >1000:

    price = (100 - 0.10 * 100) * qty

print("Cost: "+str(price))

Explanation:

This prompts the user for the quantity

qty = int(input("Quantity: "))

This calculates the price or cost, without discount

price = 100 * qty

This checks if the quantity is greater than 1000

if qty >1000:

If yes, this calculates the price or cost, after discount

    price = (100 - 0.10 * 100) * qty

This prints the calculated cost

print("Cost: "+str(price))

You might be interested in
Write pseudocode for a program which will ask a user to enter two numbers a and b. It then asks what operation is to be performe
sleet_krkn [62]

get int input for a

get int input for b

get string input for operator

if a is not int or b is not int throw exception and print error

if operator is not * / // or % throw exception and print error

if operator is * do multiplication of a and b and make answer c

else if operator is / do division of a and b and make answer c

else if operator is // do floor division of a and b and make answer c

else if operator is % do floor modulo of a and b and make answer c

print c

5 0
2 years ago
Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the elemen
Xelga [282]

Answer:

The JAVA program to implement for loop for given scenario is shown below.

public class MyProgram {

   public static void main(String args[]) {    

     int len = 5;

     int[] lowerScores = new int[len];      

     lowerScores[0] = 5;

     lowerScores[1] = 0;

     lowerScores[2] = 2;

     lowerScores[3] = -3;      

     System.out.println("The original elements of array are ");

     for(int i=0; i<len; i++)

     {

         System.out.print(lowerScores[i]+" ");

     }      

     System.out.println();

     System.out.println("The modified elements of array are ");

     for(int i=0; i<len; i++)

     {

         // if element is 0 or negative, 0 is assigned to this index

         if(lowerScores[i] <= 0)

           lowerScores[i] = 0;

       // 1 is subtracted from every non zero and positive element

         else

           lowerScores[i] = lowerScores[i] - 1;

           

       System.out.print(lowerScores[i]+" ");

     }

   }

}

OUTPUT

The original elements of array are  

5 0 2 -3 0  

The modified elements of array are  

4 0 1 0 0

Explanation:

The integer array is declared as shown.

int[] lowerScores = new int[len];

The length of the array is given by integer variable len. As per the question, we have taken four elements and size of 5 for the given array.

int len = 5;

The elements of the array are initialized inside the program with the elements given in the question.

lowerScores[0] = 5;

      lowerScores[1] = 0;

The values of the array can be changed to test the program. Also, the size of the array can be changed for testing.

As per the given scenario, if the element is greater than zero, 1 is subtracted from this element. For elements less than or equal to zero, that particular element is assigned the value of 0.

The given program implements if else statement inside for loop for this purpose.

for(int i=0; i<len; i++)

     {

         // if element is 0 or negative, 0 is assigned to this index

         if(lowerScores[i] <= 0)

           lowerScores[i] = 0;

       // 1 is subtracted from every non zero and positive element

         else

           lowerScores[i] = lowerScores[i] - 1;

     }  

5 0
1 year ago
Read 2 more answers
Type "Alley RB" into the author space on the Web of Science. You will find lots of pages of refereed scientific literature that
agasfer [191]

Answer / Explanation:

Coordination numbers, grain growth in ice, and till deformation.

The Web of Science lists 5 papers that Dr. Alley helped write and that have 1986 publication dates. Dr. Alley was studying why some parts of the Antarctic ice sheet move rapidly, and helped learn that deformation of a special type of mud beneath, called till, was involved. He also was studying the physical properties of ice cores, including why and how some crystals or grains in the ice get bigger over time. Some of the physical properties of the ice cores are related to how many different grains are touching each other, which is the coordination number.

Later, Dr. Alley used his knowledge of physical properties in ice to learn how old ice cores are, and to help learn about climate history from them. The other possibilities listed are all things that he studied, some rather closely related, but that were not published in 1986.

7 0
2 years ago
This program will calculate the rise in ocean levels over 5, 10, and 50 years, Part of the program has been written for you. The
GREYUIT [131]

Answer:

Here is the C++ program:

#include <iostream>  //to use input output functions

using namespace std;  //to identify objects cin cout

int main(){  //start of main method

     

   double risingLevel;  //declares a double type variable to hold rising level

   cin>>risingLevel;  //reads the value of risingLevel from user

   

   cout<<"Level: "<<risingLevel<<endl;  //displays the rising level

   cout << "Years: 5, Rise: " << risingLevel * 5<<endl;  //displays the rise in ocean level over 5 years

   cout << "Years: 10, Rise: " << risingLevel * 10<<endl;  //displays the rise in ocean level over 10 years

   cout << "Years: 50, Rise: " << risingLevel * 50<<endl;  //displays the rise in ocean level over 50 years

}

Explanation:

The program works as follows:

Lets say the user enters rising level 2.1 then,

risingLevel = 2.1

Now the first print (cout) statement :

cout<<"Level: "<<risingLevel<<endl;  prints the value of risingLevel on output screen. So this statement displays:

Level: 2.1          

Next, the program control moves to the statement:

   cout << "Years: 5, Rise: " << risingLevel * 5<<endl;

which computes the rise in ocean levels over 5 years by formula:

risingLevel * 5 = 2.1 * 5 = 10.5

It then displays the computed value on output screen. So this statement displays:

Years: 5, Rise: 10.5                                                                                                                          Next, the program control moves to the statement:

   cout << "Years: 10, Rise: " << risingLevel * 10<<endl;

which computes the rise in ocean levels over 10 years by formula:

risingLevel * 10 = 2.1 * 10 = 21

It then displays the computed value on output screen. So this statement displays:

Years: 10, Rise: 21                                                                                      

Next, the program control moves to the statement:

   cout << "Years: 50, Rise: " << risingLevel * 50<<endl;

which computes the rise in ocean levels over 50 years by formula:

risingLevel * 50 = 2.1 * 50 = 105

It then displays the computed value on output screen. So this statement displays:

Years: 50, Rise: 105                                                                                                                          Hence the output of the entire program is:

Level: 2.1                                                                                                                     Years: 5, Rise: 10.5                                                                                                           Years: 10, Rise: 21                                                                                                            Years: 50, Rise: 105

The screenshot of the program and its output is attached.

4 0
1 year ago
What conclusion can be made about the state of the program when the while loop terminates? Assume answer is a declared and initi
stellarik [79]

<u>Answer:</u>

<em>1. The loop will run unless the value of answer equals to Capital N.</em> The method equals is “case-sensitive” that is lower case letter and upper case letters are considered different. That “a” and “A” means the same to us, but for the method equals it is different and equals method will return false if the case is not matching.

<em>2. a (int)(Math.random() * (upper − lower) ) + lower </em>

Since we need to consider the lower limit value together to get the desired results we need to add the value of lower limit to the multiplied answer.

<em>3. b while(userGuess != secretNumber || userGuess >= lowerLimit && userGuess <= upperLimit)</em>

Here the program is required to check the while loop and exit when user guess the number or we can say the loop should continue until the user guess the number, so that is why we have taken <em>userGuess!=secretNumber. </em>Next the loop should be exited if it is not within the range or we can say that the loop should run only if the guessed number is within the upper and lower limit.<em> That is why we have opted for the condition userGues>=lowerlimit && userGuess<=upperlimit.</em> Why we have taken && as the operator is that, it’s a range of values so && operator best suit for this kind of logical condition.

3 0
1 year ago
Other questions:
  • If you want to present slides to fellow students or coworkers which productivity software should you use to create them A. Word
    14·2 answers
  • What name are input devices, output devices, and auxiliary storage devices collectively known?
    9·1 answer
  • Which are examples of copyrighted online materials? Check all that apply.
    14·2 answers
  • Ming is building an inexpensive computer to use for her online classes, and needs to purchase Windows. What is the most cost-eff
    8·1 answer
  • What output is produced by the following program segment? Why? (Recall that name.charAt(i) is the i-th character in the string,
    11·1 answer
  • Program MATH_SCORES: Your math instructor gives three tests worth 50 points each. You can drop one of the test scores. The final
    7·1 answer
  • Joe, Kate and Jody are members of the same family. Kate is 5 years older than Joe. Jody is 6 years older than Kate . The sum of
    11·2 answers
  • Provide an example by creating a short story or explanation of an instance where availability would be broken.
    10·1 answer
  • Dante has a worksheet shared with multiple users. He would like the ability to approve or reject changes that are made. Which fe
    12·1 answer
  • 1.21 LAB: Divide by x
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!