Need help answering this java programming question. Thank you in advance!
Program: Using Switch statement
Program:
import java.io.*;
import java.util.Scanner;
public class MyClass {
static char cont='N';
static String movie="Aladdin";
static boolean goingToMovies=true;
static int choice=3;
public static void main(String args[]) {
while(goingToMovies) {
System.out.printf("%nChoose a number from 1 through 5 for the movie
" + "you want to watch: ");
switch(choice)
{
case 1:
movie = "Shazam!";
break;
case 2:
movie = "A Dog's Purpose";
break;
case 3:
movie = "Aladdin";
break;
case 4:
movie = "The Kitchen";
break;
case 5:
movie = "Maleficent: Mistress of Evil";
break;
default:
System.out.printf("%nInvalid choice! Try again%n");
break;
}
System.out.printf("%nDo you want to continue? \'Y\' or \'N\':
");
if(Character.toUpperCase(cont)=='N')
{ goingToMovies = false;
}//END if cont IS 'N'
if(choice > 0 && choice < 6) {
System.out.printf("%nYou are going to see %s!%n", movie);
}//END if choice > 0 AND < 6
}//END while goingToMovies IS true
}
}
Output:
Need help answering this java programming question. Thank you in advance! g. Re-code the following as...
Rewrite the following highlighted if...else section using a switch. Only rewrite the code that you need to change, not the entire code. #include #include #define TRUE 1 #define FALSE 0 int main(void ) { enum Pops{ Coke = 1, Pepsi, Root_Beer, Grape, Seven_Up, Mountain_Dew, Dr_Pepper, Orange }; int PopSelection, DietStyle; float Price; printf( "Please enter your favourite pop: \n"); printf( "1. Coke\ n"); printf( "2. Pepsi \n" ); printf( "3. Root Beer\ n"); printf( "4. Grape \n" ); printf( "5....
Need some guidance with the following problems as I am new to Java programming. Any assistance is greatly appreciated. Thanks Using printf and specifiers for all print instructions: 1. Code the following: a. 10% is stored in a variable called discount when the customer is a student; otherwise, it stores 0%. Code this if … else control structure using the conditional operator (ternary operator). The variables discount and student have already been declared. Assume student is a boolean variable. b. ...
d. Assumecalories is already declared as an integer. Code a fall-through switchstatement by dividing calories by 100 in the controlling expression of the switch header, so the following messages print: When caloriesare 1200 through 1800: “Diet is on target.” When caloriesare 2000 through 2550: “Calorie intake ok if active.” When caloriesare any other value: “Calorie intake is either insufficient or too much!” e. Re-code 1d using double-selection ifs. You’ll use a conditional logical operator to join the sets of relational conditions (choose the right one). ...
NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION. Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...
Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...
This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions Program 2:Tip,Tax,Total int main(void) { // Constant and Variable Declarations double costTotal= 0; double taxTotal = 0; double totalBill = 0; double tipPercent = 0; // *** Your program goes here *** printf("Enter amount of the bill: $"); scanf("%lf", &costTotal); printf("\n"); // *** processing *** taxTotal = 0.07 * costTotal; totalBill...
The code snippet below is part of the restaurant menu program you previously used in the lab. Add a choice for a drink. Add the necessary code to allow the program to calculate the total price of order for the user. Assume the following price list: Hamburger $5 Hotdog $4 Fries $3 Drink $2 The program should allow the user to keep entering order until choosing to exit. At the end the program prints an order summary like this: You...
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:...
i need help converting this code to java please #include<stdio.h> typedef struct{ int pid,at,bt,ct,tat,wt,f; }process; int main() { int n,i,j,st=0,c,tot=0,pno=0,swi=0; float atat=0,awt=0; printf("enter no of processes : "); scanf("%d",&n); process a[n],temp; for (i=0;i<n;i++){ a[i].pid=i+1; a[i].f=0; printf("enter at : "); scanf("%d",&a[i].at); printf("enter the bt : "); scanf("%d",&a[i].bt); printf("--------------------------- "); } while(1){ int min=999,c=n; if (tot==n) break; for (i=0;i<n;i++){ if ((a[i].at<=st)&&(a[i].f==0)&&(a[i].at<min)){ min=a[i].at; c=i; } } if(pno!=a[c].pid) swi++; if (c==n) st++; else{ a[c].ct=st+a[c].bt; st=st+a[c].bt; a[c].tat=a[c].ct-a[c].at; atat=atat+a[c].tat; a[c].wt=a[c].tat-a[c].bt; awt=awt+a[c].wt; a[c].f=1; tot++; } } printf("...
I need help with this C code Can you explain line by line? Also can you explain to me the flow of the code, like the flow of how the compiler reads it. I need to present this and I want to make sure I understand every single line of it. Thank you! /* * Converts measurements given in one unit to any other unit of the same * category that is listed in the database file, units.txt. * Handles...