Question

clear cic: cars-input (How many cars do you want to rentln run input (Would you like to run the program Y or N,S) while r

cost-276 43*(days-7) fprintf( The cost is %d\n, cost) case (28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,

How do I get my output to print "What class of car do you want" after every loop? Here is my output, it gets stuck on asking and calculating the cost of the specific class of car i entered previously.

How many cars do you want to rent Would you like to run the program Y or NY What class of car do you want B, C, or D How many

Comments
    Answer #1

    This is because you are not 'break' after printing the cost. When it first asks for car class suppose you enter B then it will go to the while loop while carclass == 'B' and this condition is true unless we change the value of carclass. So you need to use break statement after printing the cost. Furthermore you need to use a while loop to iterate the number of cars the user want to rent. Like while cars != 0 and inside the loop decrease the the value of cars by 1.

    Add a comment
    Know the answer?
    Add Answer to:
    How do I get my output to print "What class of car do you want" after every loop? Here is my outp...
    Your Answer:

    Post as a guest

    Your Name:

    What's your source?

    Earn Coins

    Coins can be redeemed for fabulous gifts.

    Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
    Similar Homework Help Questions
    • How can I get my while loop to run until my condition in my if statement...

      How can I get my while loop to run until my condition in my if statement is met? (In MATLAB) clc%clears screen clear all%clears history close all%closes all files format long %Euler's Method %Initial conditions and setup %Projectile motion x=3;%randi(3); y=3;%randi(3); figure('color','white'); plot(x,y,'bo'); hold on wind = (-10 + 20*rand(1)); fprintf('The wind speed is %2.2i\n',wind); v0= input('Initial velocity(m/s): '); a= input('Angle of projection(in degrees): '); a=a*pi/180; h=.01; cd=.1; %cdy=.1; %cdx=(rand*2-1)/2; %cdy=(rand*2-1)/2; m=1.5; g=9.8; %acceleration due to gravity in m/s^2 %td=2*v0*sin(a)/g;...

    • Please help with my car traffic simulator! Code that I already have below, I do not know how to...

      Please help with my car traffic simulator! Code that I already have below, I do not know how to start it off! public class IntersectionSimulation { private final static int EAST_WEST_GREEN_TIME = 30 ; private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ; private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ; private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ; private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...

    • MATLAB only please I am trying to get my getdatafuntion to work. I am also trying to get all my x...

      MATLAB only please I am trying to get my getdatafuntion to work. I am also trying to get all my x's, y's, and v's to popup in the command window so I can put in any value and it will find the value for me using the equation I put in. function project_9_sjl() % PROJECT_9_SJL project_9_sjl() is the driver function for the program. % %    Name: Scott Lawrence %   Date: 3/27/2019 %   Class: CMPSC 200 %   Description: Determine the optimal...

    • (JAVA) How do I access the values calculated in a for loop after the for loop...

      (JAVA) How do I access the values calculated in a for loop after the for loop is finished iterating? My task is to calculate subtotals using values from the user dependent on how many items they are buying. I used a nested for loop with if loops to calculate the subtotals based on what the price is (user input) and quantity of items (user input). I was able to get the loop to run how I need to; however, after...

    • I want to see the work written out because I do not understand how a for...

      I want to see the work written out because I do not understand how a for loop works without running it on MatLab Exercise 13 (2 pts.): Predict the output that appears in Matlab's command window when the following Matlab program is run (REMEMBER to SHOW SOME WORK!) clear;clc a = 3; c=2; d = zeros (1,5) -2; for m - 1:5 x = (m-1)"c; y = (-1)^n; z=x-y; d(m) = z + 1; end

    • I need help fixing my python3 code. I am trying to get my Monty hall game...

      I need help fixing my python3 code. I am trying to get my Monty hall game working correctly. Below is my code. When I run the code it repeats the first question and doesn't work until the 3rd attempt or sometimes more than that. How do I fix this? I also need to be able to make it run 5 times in a row.(like ask the user at least 5 times, so it is re-playable. I added a image of...

    • This is my current output for my program. I am trying to get the output to...

      This is my current output for my program. I am trying to get the output to look like This is my program Student.java import java.awt.GridLayout; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import javax.swing.JFileChooser; public class Student extends javax.swing.JFrame {     BufferedWriter outWriter;     StudentA s[];     public Student() {         StudentGUI();            }     private void StudentGUI() {         jScrollPane3 = new javax.swing.JScrollPane();         inputFileChooser = new javax.swing.JButton();         outputFileChooser = new javax.swing.JButton();         sortFirtsName = new...

    • create case 4 do Method 1:copy item by item and skip the item you want to...

      create case 4 do Method 1:copy item by item and skip the item you want to delete after you are done, delete the old file and rename the new one to the old name. #include int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1:...

    • Java - Car Dealership Hey, so i am having a little trouble with my code, so...

      Java - Car Dealership Hey, so i am having a little trouble with my code, so in my dealer class each of the setName for the salesman have errors and im not sure why. Any and all help is greatly appreciated. package app5; import java.util.Scanner; class Salesman { private int ID; private String name; private double commRate; private double totalComm; private int numberOfSales; } class Car { static int count = 0; public String year; public String model; public String...

    • Help! i can't get the correct output for this question: Write a program that will read...

      Help! i can't get the correct output for this question: Write a program that will read in an integer from the user and test to see whether or not it is prime. You are to determine if each integer read is prime or not, and output the result to the screen as shown below. If a number is prime, your output should read: 101 = 1 x 101 101: PRIME Number For a number that turns out not to be...

    ADVERTISEMENT
    Free Homework Help App
    Download From Google Play
    Scan Your Homework
    to Get Instant Free Answers
    Need Online Homework Help?
    Ask a Question
    Get Answers For Free
    Most questions answered within 3 hours.
    ADVERTISEMENT
    ADVERTISEMENT
    ADVERTISEMENT