An airline describes airfare as follows. A normal ticket's base cost is $300. Persons aged 60 or over have a base cost of $290. Children 2 or under have $0 base cost. A carry-on bag costs $10. A first checked bag is free, second is $25, and each additional is $50. Given inputs of age, carry-on (0 or 1), and checked bags (0 or greater), compute the total airfare. Hints: First use an if-else statements to assign airFare with the base cost Use another if statement to update airFare for a carryOn Finally, use another if-else statement to update airFare for checked bags Think carefully about what expression correctly calculates checked bag cost when bags are 3 or more

Answers

Answer 1

Answer:

The program in Python is as follows:

age = int(input("Age: "))

carryOn = int(input("Carry on Bags [0 or 1]: "))

checkedBags = int(input("Checked Bags [0 or greater]: "))

airFare = 300

if age >= 60:

   airFare = 290

elif age <= 2:

   airFare = 0

if carryOn ==  1:

   airFare += 10

if checkedBags ==  2:

   airFare += 25

elif checkedBags >  2:

   airFare += 25 + 50 * (checkedBags - 2)

print("Airfare: ",airFare)

Explanation:

This gets input for age

age = int(input("Age: "))

This gets input for carry on bags

carryOn = int(input("Carry on Bags [0 or 1]: "))

This gets input for checked bags

checkedBags = int(input("Checked Bags [0 or greater]: "))

This initializes the base cost to 300

airFare = 300

This updates the base cost to 290 for adults 60 years or older

if age >= 60:

   airFare = 290

This updates the base cost to 0 for children 2 years or younger

elif age <= 2:

   airFare = 0

This updates the airFare if carryOn bag is 1

if carryOn ==  1:

   airFare += 10

if carryOn bag is 0, the airFare remains unchanged

This updates the airFare if checkedBags is 2. The first bag is free; so, only the second is charged

if checkedBags ==  2:

   airFare += 25

This updates the airFare if checkedBags greater than 2. The first bag is free; so, only the second and other bags is charged

elif checkedBags >  2:

   airFare += 25 + 50 * (checkedBags - 2)

if checkedBags is 0 or 1, the airFare remains unchanged

This prints the calculated airFare

print("Airfare: ",airFare)


Related Questions

c Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. flowchart

Answers

Answer:

hope this helps and do consider giving a brainliest to the ans if it helped.

Explanation:

//program to check if the entered grid is magic square or not

/**c++ standard libraries

*/

#include<bits/stdc++.h>

using namespace std;

/**function to check whether the entered grid is magic square or not

*/

int isMagicSquare(int arr[3][3]){

  int i,j,sum=0,sum1=0,rsum,csum;

  for(i=0;i<3;i++){

      sum+=arr[i][i];

      sum1+=arr[i][2-i];

  }

  if(sum!=sum1){

      return 0;

  }

 

  for(i=0;i<3;i++){

      rsum=0;

      csum=0;

      for(j=0;j<3;j++){

          rsum+=arr[i][j];

          csum+=arr[j][i];

      }

      if(sum!=rsum){

          return 0;

      }

      if(sum!=csum){

          return 0;

      }

  }

  return 1;

}

/** main function to get user entries and

* call function

* and print output

*/

int main(){

  int i,j,arr[3][3]={0};

  for(i=0;i<3;i++){

      for(j=0;j<3;j++){

          cout<<"Enter the number for row "<<i<<" and column "<<j<<" : ";

          cin>>arr[i][j];

      }

  }

  int ret = isMagicSquare(arr);

  if(ret==1){

      cout<<"This is a Lo Shu magic square"<<endl;

  }

  else{

      cout<<"This is not a Lo Shu magic square"<<endl;

  }

  return 0;

}

Write a Java program named Problem 3 that prompts the user to enter two integers, a start value and end value ( you may assume that the start value is less than the end value). As output, the program is to display the odd values from the start value to the end value. For example, if the user enters 2 and 14, the output would be 3, 5, 7, 9, 11, 13 and if the user enters 14 and 3, the output would be 3, 5, 7, 9, 11, 13.

Answers

Answer:

hope this helps

Explanation:

import java.util.Scanner;

public class Problem3 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter start value: ");

       int start = in.nextInt();

       System.out.print("Enter end value: ");

       int end = in.nextInt();

       if (start > end) {

           int temp = start;

           start = end;

           end = temp;

       }

       for (int i = start; i <= end; i++) {

           if (i % 2 == 1) {

               System.out.print(i);

               if (i == end || i + 1 == end) {

                   System.out.println();

               } else {

                   System.out.print(", ");

               }

           }

       }

   }

}

Other Questions
Popcorn at the Movies - Exit Slip You and a friend go to the movies and decide to share a large bucket of popcorn. Write a story to describe the graph. what do you think? So why don't t apes walk upright like us? Need help what's the answer Important test and i have limited time so please hurry Write the ratio, Explain what the ratio means . 6 basketballs to 4 soccer balls Which of these is not an example of a transition Help mee please :( Spanish 5kgP= 210 N[2]2 kg3 kg5 kgP = 210 NM = 0.21411 kg which anion forms a neutral compound when combined with a group 2 monatomic cation in a 1:1 ratio?A) Fluoride.B)Nitrate.C)Phosphide.D)Sulfide. 3. A mysterious metal medallion has a mass of 3,088 grams. Water is poured into a graduated glass container with a 10-by-10 cm square base with a water level of 53.0 cm. The medallion is dropped into the container and the water level rises to 54.6 cm. Find the volume and the density of the What is an equation of the line that passes through the points (-4,-3) and (3,-3) A Rectangle has diagonals of length 13 cm and width is 5 cm. Find the length of its side? The way of speaking a word is called its origin.Please select the best answer from the choices providedO TO F An isosceles triangle has an angle that measures 26. Which other angles could be in thatisosceles triangle? Choose all that apply. Yall what do u think my Artist's name should be? Find the value of x Explain how you can determine if an object is accelerating. Give two examples Why should a person warm up before physical activity?Do implying immune functionTo reduce injuryTo increase response timeTo stabilize their emotion state A sequence is shown below6, 8, 10, 12, 14Which function represents this sequence?A. f(n) = 4 + 2(n - 1)B. f(n) = 4 + 2(n + 1)C. f(n) = 6 + 2(n - 1)D. f(n) = 6 + 2(n + 1) If you place a 29-foot ladder against the top of a building and the bottom of the ladder is 16 feet from the bottom of the building, how tall is the building? Round to the nearest tenth of a foot.