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
torisob [31]
2 years ago
4

python A credit card company computes a customer's "minimum payment" according to the following rule. The minimum payment is equ

al to either $10 or 2.1% of the customer's balance, whichever is greater; but if this exceeds the balance, then the minimum payment is the balance. Write a program to print out the minimum payment using min and max. Assume that the variable balance contains the customer's balance. Your program does not need to print the dollar sign. Example 1: if your balance is 1000, then your program should print 21.
Computers and Technology
1 answer:
larisa86 [58]2 years ago
6 0

Answer:

# user is prompt to enter balance

balance = int(input("Enter your balance: "))

# 21% of the balance is calculated

balancePercent = 0.021 * balance

# The greater of $10 and balance persent is assigned to minimumPayment using max()

minimumPayment = max(10, balancePercent)

# the least between minimumPayment and the balance is assigned to minimumPayment using min()

minimumPayment = min(minimumPayment, balance)

# minimumPayment is displayed to user

print(minimumPayment)    

Explanation:

The program is written in Python3 and well commented. First the user is prompt to enter the balance. Then 21% of the balance is computed and assigned to balancePercent. Then using max( ) we find the maximum between 10 and the balancePercent which is assigned to minimumPayment.

The we use min( ) to find the minimum between the existing minimumPayment and the balance and assigned to minimumPayment.

The minimumPayment is then displayed to user.

max( ) and min( ) are inbuilt function of python that is use to get the maximum and minimum of the passed arguments.

You might be interested in
In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings,
vampirchik [111]

Answer:

Here is the corrected program:

import java.util.Scanner; //to accept input from user

public class 02_14_Activity_one { //class name

    public static void main(String[] args) { //start of main method

    Scanner scan = new Scanner(System.in); //creates Scanner class object

  System.out.println("Enter first string"); //prompts user to enter first string

          String s1 = scan.nextLine(); //reads input string from user

  System.out.println("Enter second string"); //prompts user to enter second string

          String s2 = scan.nextLine(); //reads second input string from user

    System.out.println("Enter number of letters from each word"); //enter n

          int n = scan.nextInt(); //reads value of integer n from user

          System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));

         } } //uses substring method to print a string made up of the first n letters of s1 and the last n letters of s2.

Explanation:

The errors were:

1.

Scanner scan = Scanner(System.in);

Here new keyword is missing to create object scan of Scanner class.

Corrected statement:

 Scanner scan = new Scanner(System.in);

2.

String s1 = nextLine();  

Here object scan is missing to call nextLine() method of class Scanner

Corrected statement:

String s1 = scan.nextLine();

3.

String s2 = Scanner.nextLine();

Here class is used instead of its object scan to access the method nextLine

Corrected statement:

String s2 = scan.nextLine();

4.

String n = scan.nextLine();

Here n is of type String but n is a whole number so it should be of type int. Also the method nextInt will be used to scan and accept an integer value

Corrected statement:

int n = scan.nextInt();

5.

System.out.println(s1.substring(1,n-1) + s2.substring(s1.length()-n));

This statement is also not correct

Corrected statement:

System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));

This works as follows:

s1.substring(0,n) uses substring method to return a new string that is a substring of this s1. The substring begins at the 0th index of s1 and extends to the character at index n.

s2.substring(s2.length() - n ) uses substring method to return a new string that is a substring of this s2. The substring then uses length() method to get the length of s2 and subtracts integer n from it and thus returns the last n characters of s2.

The screenshot of program along with its output is attached.

7 0
2 years ago
Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second ar
Serjik [45]

Answer:

Written in Java

public static void printArray(int myarr[], String s){

       for(int i = 0; i<myarr.length;i++){

           System.out.print(myarr[i]+s);

       }

   }

Explanation:

This defines the static method alongside the array and the string variable

public static void printArray(int myarr[], String s){

The following iteration iterates through the elements of the array

       for(int i = 0; i<myarr.length;i++){

This line prints each element of the array followed by the string literal

           System.out.print(myarr[i]+s);

       }

   }

The method can be called from main using:

<em>printArray(myarr,s);</em>

Where myarr and s are local variables of the main

5 0
2 years ago
"In Windows, what two terms describe the active partition on an MBR drive, and the location where the Windows operating system i
Oxana [17]

Answer:

Boot partition and system partition

Explanation:

System partition is the primary partition that is used as the active boot partition,it saves boot files and all files that will be used.  System partition is also known as the system directory or root directory and is usually given the identifier "c"

Boot partition is the disk partition that holds the files for the operating system files Windows operating system (either XP, Vista, 7, 8, 8.1 or 10), it works with the system partition and tells the computer where to look when starting. It given the identifier of letter "D" or "E"

5 0
2 years ago
Read 2 more answers
How can you check an orthographic drawing to be sure there are no missing lines
user100 [1]
With an magnify glass
4 0
2 years ago
Leah wants to create a PowerPoint presentation for a history report about the progressive era in the 1900s. To
Nutka1998 [239]

Answer:

File

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • Computer hardware had been designed to run a single operating system and a single app, leaving computers vastly underutilized. o
    15·1 answer
  • Strlen("seven"); what is the output?
    14·1 answer
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds o
    15·2 answers
  • What technology gets its name from the notion that it ignores the traditional A, B, and C class designations for IP addresses?
    14·1 answer
  • In this assignment, you are provided with working code that does the following: 1. You input a sentence (containing no more than
    14·1 answer
  • The signature area in a cover letter includes the sender's first and last name, followed by his/her job title (if applicable). *
    13·1 answer
  • Write a method named removeDuplicates that accepts a string parameter and returns a new string with all consecutive occurrences
    7·1 answer
  • ) A byte is used to represent a single character in the computer ______<br> true or false?
    14·2 answers
  • **Click the photo** Put the steps in order to produce the output shown below. Assume the indenting will be correct in the progra
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!