Question

How can you solve this problem using if statements? CSCI 206 Lab Date: 27 March 2020 Lab 8 - Coffee Switches Due: 2 April 2020 Please submit your lab on Moodle. Since we are not

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
   int roast,flavor,flag=1;
   char *word,*word2;
   printf("Welcome to my Coffee Machine\n");
   while(flag==1){
      
       printf("\n\nwhat type of coffee would like ?\nEnter 1 for dark roast, 2 for light roast, 3 for decaffeinated :");
       scanf("%d",&roast);
       printf("what flavor would like ?\nEnter 1 for mocha, 2 for caramel, 3 for no flavor :");
       scanf("%d",&flavor);
       switch(roast){
           case 1:
               word= "dark roast";
               break;
           case 2:
               word= "light roast";
               break;
           case 3:
               word= "decaffeinated";
               break;
       }
       switch(flavor){
           case 1:
               word2= " mocha";
               break;
           case 2:
               word2= " caramel";
               break;
           case 3:
               word2= "out any flavor";
               break;
       }
       printf("\n\nhere is your %s with%s",word,word2);
       printf("\n\nDid you want another coffee (yes-1 | no-0) :");
       scanf("%d",&flag);
   }
   printf("come again soon!");
}

if you have any queries regarding answer, please ask me at comment section.

please give like.

thank you.

Add a comment
Know the answer?
Add Answer to:
How can you solve this problem using if statements? CSCI 206 Lab Date: 27 March 2020...
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
  • Write a program that inputs a month, day, and year from the user and outputs the corresponding date in the following two standard date formats:

    THE PROBLEM:It makes it easier if you use switch statements for some part of the homework. Write a program that inputs a month, day, and year from the user and outputs the corresponding date in the following two standard date formats:6/12/2005  June  12,2005Also your program must print the name of any holiday associated with the date.For example:3/17/2010  March 17, 2010  St. Patrick's Day Your program should ask the user how many times the user wants to run the code and then...

  • CSCI 161 - Lab 2: "Give Me a Second!" Overview This lab will have you developing...

    CSCI 161 - Lab 2: "Give Me a Second!" Overview This lab will have you developing a program that asks the user to input a time period as a number of seconds and in turn calculates the whole number of days, hours and minutes that are contained within the entered time period. Refer to the "Output Format" below for an example of what your program must do. The objectives of this lab are to reinforce and help teach: proper Java...

  • Lab 5 Instructions For Lab 5, you will be writing a more complex modular program that...

    Lab 5 Instructions For Lab 5, you will be writing a more complex modular program that uses at least two arrays, and has at least one loop that accesses the data in the arrays. As long as your program satisfies the requirements listed below, you are free to design and write any type of program that you care to. You are encouraged to be creative, and pick something that has meaning for you, because you'll have more fun. Feel free...

  • Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to...

    Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write...

  • Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in th...

    using matlab Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in the decimal to octal program Introduction: In file systems on servers (think of websites like Google, Amazon, etc.), permission to access the files come from the octal number system. Given an octal quadruple, permissions are defined for the user, the group, and other as follows: Permission First Digit Second Digit Third Digit Fourth Digit Always 01 (User-u) 0 」(Group-g) | (Other-o) Read (r) Write...

  • In this lab, you complete a partially written Java program that includes two methods that require...

    In this lab, you complete a partially written Java program that includes two methods that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Next, the program passes the value to another method that computes the product of all the whole numbers up to...

  • In this lab, you complete a partially written Java program that includes two methods that require...

    In this lab, you complete a partially written Java program that includes two methods that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Next, the program passes the value to another method that computes the product of all the whole numbers up to...

  • Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...

    Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...

  • In this lab, you complete a partially written Java program that includes methods that require multiple...

    In this lab, you complete a partially written Java program that includes methods that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to methods named calculateSum(), calculateDifference(), and calculateProduct(). The methods compute the sum of the two values, the difference between the two values, and the product of the two values. Each method should perform the appropriate computation and display the results. The source code file provided for this lab...

  • The goal of this problem is to practice using appropriate branching statements. You will add to...

    The goal of this problem is to practice using appropriate branching statements. You will add to the main method to take in user input and output a message based on the input. This program emulates a detective questioning an eye-witness of a murder. The detective has three suspects each with a potential murder weapon. Based on the eye-witness's user input, the detective will reach a conclusion about the murderer and the murder weapon. If the witness input is "Amos" the...

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