EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 2, Problem 11RQ
Program Description Answer
The remainder operator is represented by percent sign (%).
Hence, the correct answer is option “D”.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
4.7 for repetition
#include <iostream>#include <iomanip>using namespace std;int main(){long USD, maxUSD; // Amount in USDdouble rate; // Exchange rate USD <-> MYRcout << "\n* * * * TABLE OF EXCHANGE * * * *\n ";cout << "* United State Dollar (USD) to Malaysia Ringgit (MYR) *\n\n";cout << "\nPlease give the rate of exchange: ";cout <<" \n\n 1 USD in RM MYR: ";cin >> rate;cout << "\n Please enter the USD you want to change: ";cin >> maxUSD;// Outputs the table & Titles of columns:cout << "\n If Rate Now is : " << rate << endl;cout << "\n so, USD to RM exchange is : "<< endl;cout << '\n'<< setw(12) << "USD" << setw(20) << "MYR";cout << '\n'<< setw(16) << "---------------------------------------------" ;cout << '\n'<< setw(24) << " >>> " ;// Formatting RM-MYR:cout << setprecision(2) << endl;long lower, upper,…
Need help correcting the 24-hour clock as its showing as regular time!
#include <iostream>#include <ctime>#pragma warning(disable : 4996)
using namespace std;
time_t now = time(0);tm* local = localtime(&now);
int hour = local->tm_hour;int minutes = local->tm_min;int sec = local->tm_sec;
// Function to display the 12-hour clockvoid Clock12() { // Converts 24-hour clock to 12-hour if (hour > 12) { hour -= 12; } cout << "*****************************" << " " << "*****************************\n"; cout << "* 12-Hour Clock *" << " " << "* 24-Hour Clock *\n"; cout << "* " << (hour < 10 ? "0" : "") << hour << ":" << (minutes < 10 ? "0" : "") << minutes << ":" << (sec < 10 ? "0" : "") << sec << (local->tm_hour < 12 ? " AM" : " PM") << " * ";}
// Function to display the 24-hour…
Please change this program to #include<stdio.h>
#include<iostream>#include<conio.h>using namespace std;int main(){ char V,x; int charges; cout<<"Select your vehicle:\nC\t=Car\nB\t=Bus\nT\t=Truck"; cin>>V; cout<<"Enter days to park the vehicle : "; cin>>x; switch(V) { case 'C': { charges=x*20; cout<<"Charges for Car is Rs."<<charges ; break; } case 'B': { charges=x*25; cout<<"Charges for Car is Rs."<<charges; break; } case 'T': { charges=x*30; cout<<"Charges for Bus is Rs."<<charges; break; } default: cout<<"Invalid input"; } return 0;}
Chapter 2 Solutions
EBK JAVA PROGRAMMING
Ch. 2 - Prob. 1RQCh. 2 - Prob. 2RQCh. 2 - Prob. 3RQCh. 2 - Prob. 4RQCh. 2 - Prob. 5RQCh. 2 - Prob. 6RQCh. 2 - Prob. 7RQCh. 2 - Prob. 8RQCh. 2 - Prob. 9RQCh. 2 - Prob. 10RQ
Ch. 2 - Prob. 11RQCh. 2 - Prob. 12RQCh. 2 - Prob. 13RQCh. 2 - Prob. 14RQCh. 2 - Prob. 15RQCh. 2 - Prob. 16RQCh. 2 - Prob. 17RQCh. 2 - Prob. 18RQCh. 2 - Prob. 19RQCh. 2 - Prob. 20RQCh. 2 - Prob. 1PECh. 2 - Prob. 2PECh. 2 - Prob. 4PECh. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - Prob. 7PECh. 2 - Prob. 8PECh. 2 - Prob. 9PECh. 2 - Prob. 10PECh. 2 - Prob. 11PECh. 2 - Prob. 12PECh. 2 - Prob. 13PECh. 2 - Prob. 14PECh. 2 - Prob. 15PECh. 2 - Prob. 16PECh. 2 - Prob. 1GZCh. 2 - Prob. 3GZCh. 2 - Prob. 1CPCh. 2 - Prob. 2CP
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- #include <iostream>using namespace std;int main(){ double hours, pay, gross, regular, OT, OT1; cout << "Enter pay rate:"; cin >> pay; cout << "Enter hours worked: "; cin >> hours; if (hours >= 40) { regular = hours * pay; OT = 0; OT1 = 0; gross = regular + OT + OT1; cout << "Regular hours: " << hours << "@" << pay << " $" << regular << endl; cout << "Ovetime hours: " << hours - 40 << "@" << pay << " $" << OT << endl;; cout << "Ovetime1 hours: " << "0" << "@" << pay << " $" << OT1 << endl;; cout << "Total gross pay: " << gross; } else if (hours < 40 && hours >= 54) { regular = 40 * pay; OT = regular + (hours - 40) * (pay * 1.5); OT1 = 0; gross = regular + OT + OT1; cout <<…arrow_forward1. Generate a number of random integer values within a given rangeRequirements: - Ask the user the following info: a. How many random numbers they would like to have b. What is the upper and lower limit (e.g. range)? - Generate that many random numbers within that given range - Do not accept negative values for the count, lower or upper limit Help: Here is a simple example on how to generate one random number #include <iostream>#include <ctime>using namespace std; int main(){ /* get the current system time and use it as the seed to generate*/ srand( time(0) ) ; /* retrieve the next random number */ int num = rand() ; /* print it out */ cout << "Random number: " << num << endl; return 0 ;}Note: you need to call "srand" only once (e.g. not inside a loop). Extend your random generating program to make sure that the numbers are unique. In another words, if the number has been generated and appear…arrow_forward#include <iostream>#include <iomanip>#include <cmath>using namespace std; #define PROPERTY_TAX_RATE_PER_YEAR 1.25#define COST_OF_UTILITIES_PER_MONTH 300.00#define COST_OF_INSURANCE_PER_YEAR 550.00 void inputData(double& sellingPrice, double& interestRate, int& durationOfLoan); void handleAllComputations(double sellingPrice,double interestRate,int durationOfLoan,double downPaymentRate,double& downPayment,double& amountOfLoan,double& mortgagePayment,double& propertyTax,double& costOfInsurance,double& totalMonthlyHouseCost); double calculateDownPayment(double sellingPrice, double downPaymentRate);double calculateAmountOfLoan(double sellingPrice, double downPayment);double calculateMortgagePayment(double amountOfLoan,double interestRate,int durationOfLoan); void outputResults(double sellingPrice,double downPayment,double amountOfLoan,double interestRate,int durationOfLoan,double mortgagePayment,double propertyTax,double…arrow_forward
- CHALLENGE ACTIVITY Use C++ 1.11.2: Outputting all combinations. Output all combinations of character variables a, b, and c, in the order shown below. If a = 'x', b = 'y', and c = 'z', then the output is:xyz xzy yxz yzx zxy zyx #include <iostream>using namespace std; int main() { char a; char b; char c; cin >> a; cin >> b; cin >> c; a = 'x'; b = 'y'; c = 'z'; cout << cout << endl; return 0;}arrow_forward4.4 Arithmetic Operator #include <iostream>using namespace std;main (){ int a, b, c, sum; cout <<"An arithmetic operator program\n"; cout <<"\nenter first integer, a:"; cin >>a; cout <<"\nenter second integer, b:"; cin >> b; cout <<"\nenter thrid integer, c:"; cin >> c; sum = a * b - c % 3; cout << "\nthe sum of (a * b - c % 3) is " << sum << endl; return 0;} Can you predict what is the output will be before run the code?arrow_forwardNeed help having code going past 21 hours on 24-hour clock and changing over to AM after 00:00! Thanks in advance #include <iostream>#include <ctime>//Had trouble with the variable localtime#pragma warning(disable : 4996) using namespace std; time_t now = time(0);tm* local = localtime(&now); int hour = local -> tm_hour;int minutes = local -> tm_min;int sec = local -> tm_sec; // Function to display the 12-hour clockvoid Clock12() { // Converts 24-hour clock to 12-hour if (hour > 12) { hour -= 12; } cout << "*****************************" << " " << "*****************************\n"; cout << "* 12-Hour Clock *" << " " << "* 24-Hour Clock *\n"; cout << "* " << (hour < 10 ? "0" : "") << hour << ":" << (minutes < 10 ? "0" : "") << minutes << ":" << (sec < 10 ? "0" : "") << sec <<…arrow_forward
- plz correct this code #include <iostream>using namespace std;int main(){int i,sum;sum=0;i=1;do{ cout<<\n \nDisplay ten terms of Natural number and their sum:\n; cout<<------------------------------\n"; cout<< "the natural numbers up to 10th terms are\n"; cout<<i;sum=sum+i;i++;}while(i<=10);cout<<" The sum of the first 10 natural numbers is?"<< sum;}arrow_forwardI assume the following 2 codes express the same meaning? int myvar; int * myptr = &myvar; and int myvar; int * myptr; myptr = &myvar;arrow_forwardArithmetic Operator #include <iostream>#include <stdlib.h>using namespace std;main (){int a, b, c, d, e, sum1=1, sum2=2;cout <<"Assignment operator program"<<endl;cout <<"\nenter first integer, a:";cin >>a;cout <<"enter second integer, b:";cin >> b;cout <<"enter thrid integer, c:";cin >> c; b -= a * c;a /= c;sum1 += a % b + 7 * c;cout << "\nthe sum1 is" << sum1 << endl; system("pause"); cout <<"\nenter forth integer, d:";cin >> d;cout <<"enter fifth integer, e:";cin >> e;sum2 -= e * 2 + d;cout << "\nthe sum2 is" << sum2 << endl;d = b * 2;e = a + 1;cout << "\nValue a =" <<a;cout << "\nValue b =" <<b;cout << "\nValue c =" <<c; cout << "\nValue d =" <<d;cout << "\nValue e =" <<e<<endl;return 0;} 4.5) Can you predict what is the output will be before run the code?arrow_forward
- #include <iostream> using namespace std; int main(){char ch;cout<<"Welcome to Freddy's Pizza"<<endl<<endl; cout<<"Pizza Menu: "<<endl<<endl;cout<<" 1: Vegetarian Pizza "<<endl;cout<<" 2: Chicken Dynamite Pizza"<<endl; cout<<" 3: Meat Lovers Pizza"<<endl;int choice;cout<<"Which pizza would you like to try? "; cin>>choice;cout<<endl;switch(choice){case 1:cout<<"What size of pizza would you like(L,M,S)? ";cin>>ch;cout<<endl<<endl<<endl;cout<<"Pizza Order: "<<endl;cout<<"Pizza Name: Vegetarian Pizza"<<endl;cout<<"Preparation time: 15 minutes"<<endl;cout<<"Calories: 25"<<endl;if(ch == 'L' || ch=='l'){cout<< "Pizza Price: 4 OMR"<<endl;}else if(ch == 'M' || ch=='m'){cout<< "Pizza Price: 3 OMR"<<endl;}else if(ch == 'S' || ch=='s'){cout<<"Pizza Price: 2 OMR"<<endl;}cout<<"Toppings:…arrow_forward#include <iostream> using namespace std; int main() { string c_name ; string car_n; int n, member_n , total ,d; char choice; cout<< "Muscat Auto Workshop"<<endl<<endl; cout<< "Enter customer name : ";cin>>c_name; cout<<" Enter car plate number : ";cin>>car_n; cout<<" choice the required service "<<endl; cout<<" 1-Basic Tuning : 50 OMR "<<endl; cout<<" 2-Software Re-installation : 60 OMR "<<endl; cout<<" 3-Parts Replacement : 100 OMR"<<endl; cout<<" 4-Body Paint : 120 OMR"<<endl; cin>>n; if(n==1) { cout<<" charges before discout = 50 OMR "<<endl; } else if ( n==2) { cout <<" charges before discount = 60 OMR "<<endl; }else if (n==3) { cout<<" charges before discount = 100 OMR "<<endl; }else if (n==4 ) { cout<<" charges before discount = 120 OMR"<<endl; } cout<<" Do you…arrow_forwardI get an error when I submit my program. My code is as follows #include<iostream> using namespace std; int main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); // show decimals even if not needed cout.precision(2); // two places to the right of the decimal // TODO: enter the missing types below int time; float ticketPrice; char destination; //'C'=Chicago, 'P'=Portland, 'M'=Miami char typeOfDay; //'D'=weekDay 'E'=weekEnd bool isDayTime = false,isWeekend; cout << "Welcome to Fordham Airlines!" << endl; cout << "What is your destination? ([C]hicago, [M]iami, [P]ortland) "; cin >> destination; cout << "What time will you travel? (Enter time between 0-2359) "; cin >> time; // TODO: set isDayTime to true if time 5AM or later, but before 7PM if(time>500&&time<1900){ isDayTime = true; } cout << "What type of day are you traveling? (week[E]nd or week[D]ay) "; cin >> typeOfDay; // TODO: set isWeekend to true if typeOfDay…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,