Reimplement the digital clock from the preceding exercise, representing the time as the minutes from midnight. This makes the pulse member function very easy, but you have to work harder to recover the hours and minutes. For example, 100 minutes after midnight is 1 hour and 40 minutes. C++
Q: Write a C program that reads an integer from the user (keyboard), namely n. Your program should…
A: Using the basic C header files for keywords and functions. For finding the sum of digits we use…
Q: Exercise #2 convert the following infix Algebraic expressions to postfix (x + y)+4^(a+z*3)…
A: 1. (x+y)+4^(a+z*3) = xy++4^(a+z*3) =xy++4^(a+z3*) =xy++4^az3*+ =xy++4az*+^ =xy+4az*+^+
Q: Write a C++ program that prompts the user for the length and the width of a rectangle. The program…
A: Start Input length Input width Calculate Area Calculate Perimeter Display Area Display Perimeter…
Q: Write a program that reads any infix notation (without parentheses) and converts it into a prefix…
A: Code:- #include <stdio.h> #include <stdlib.h> #include <string.h> struct Stack{…
Q: Write C program to find and print the number of fraction digits in a real number. For example, if…
A: Required: Required code with comments for explanation and screenshot of both code and output has…
Q: Write a program in C++ that converts decimal numbers to binary, hexadecimal, and BCD. You are not…
A: Program: #include <iostream> #include <string> using namespace std; string…
Q: Write a C program that prompts the user to enter a positive integer between 100 and 9999 inclusive).…
A: Logic: - first check the range of input number. then count the number of digits if(count==3)…
Q: First find the value of each of the following arithmetic expressions in C. Then step by step, show…
A:
Q: Write a c++ program to read 20 different numbers and find the maximum number among them? then if it…
A: Algorithm: Start Set i=0 Set max=0 IF i<20 go to step 5 otherwise go to step 8. READ A[i] IF…
Q: Write a C program that generates a social security code from a user's entered social security…
A: int add_digits(int x) calculate sum of all digits recursively Base step: x == 0…
Q: Write a c program that calculates the potential energy of 3 charges q1=1, q2=2, q3=3 located at…
A: please do upvote for my efforts thanks! answer: code #include…
Q: Write a C++ program that receives a series of numbers from the user and allows the user to press the…
A: C++ Program for above : #include <bits/stdc++.h> using namespace std; int main() {…
Q: Write C program to find and print the number of fraction digits in a real number. For example, if…
A: Algorithm: Start Read a real number Convert it to string Traverse the string. After reaching '.',…
Q: Rewrite this Python code in Haskell language, so that the looping condition and the body of the loop…
A: approximatePi::[pi]->double pi = 0.0 i = 1 pi1 = 5.0 pi2 = 0.0
Q: Write a C++ program (using for) that displays the numbers between 0 and 20 that are divisible by 3…
A: We have to search for numbers from 0 to 20 Then we have to check whether the number is exactly…
Q: Write a code in C++: Write a program to factor a polynomial of the form x² + bx + c, where b and c…
A: #include <iostream> //Including iostream header file#include <cmath> // Including…
Q: Write a C++ program in which you have to generate nth term of the given sequence: 0, 3, 8, 15, 24,…
A: Given Sequence: 0, 3, 8, 15, 24, 35, 48, 63, .... Requirement: Write a program in C++ language that…
Q: Write a program by using c++ that inputs a number and checks whether it is a perfect number or not.…
A: Program: #include<iostream> using namespace std; bool perfect(int n) { int sum = 0;…
Q: Write a C program that reads an integer from the user (keyboard), namely n. Your program should…
A: Actually, program is a executable software that runs on a computer.
Q: Write a c++ program that asks the user to enter a number and then prints all the divisors of that…
A: #include <iostream> using namespace std; int main(){ int num = 0; cout<<"\n Enter…
Q: Write a program c++ that receives the date from the user in the form of 3 correct numbers, the…
A: Lets see the solution.
Q: Write a C program hoursToDays.c that will convert a number of hours to days and hours the time is…
A: As per the requirement program is developed. Algorithm: Step 1: Write the main method Step 2: Define…
Q: Write java function that takes three numbers and returns max from three using ternary operators…
A: GIVEN: Write java function that takes three numbers and returns max from three using ternary…
Q: Write a C program that determines the day number (1 to 366) in a year for a date that is provided as…
A: The C code is given below:
Q: Write an integrated program that asks you to enter three real positive values and then prints the…
A: In the java program, add the necessary libraries to it. For example, to obtain the three inputs from…
Q: Rewrite Exercise 3.4 using the following func tion to return the area of a pentagon: def area(s):
A: Given: Rewrite Exercise 3.4 using the following func tion to return the area of a pentagon: def…
Q: A. Write a program in "SUM.C" which reads two integers and prints out the sum, the difference and…
A: To do: Find sum, difference, product, division and remainder of two numbers. The program ask user to…
Q: Write a program in C++ to find the gcd of numbers a,b void ged(int a, int b) and print it Sample…
A: We have to give a program in C++ to find the gcd of numbers a,b
Q: Write a program in C++ that takes in a line of text as input, and outputs that line of text in…
A: Actually, the code has given below:
Q: Write a C program (using DO WHILE loop) to print inputted number by the user while showing only 10…
A: I give the code along with output and code screenshots
Q: gram in C that displays the classic BINGO game, displays a BINGO card (5x5 square), and tests the…
A: Write a program in C that displays the classic BINGO game, displays a BINGO card (5x5 square), and…
Q: Write a C++ program that asks the user to enter a month (1 for January, 2 for February, etc.) and…
A: Given: Write a C++ program that asks the user to enter a month (1 for January, 2 for February, etc.)…
Q: In C++, write a program for the user to enter two numbers, and then press a for addition, b for…
A: Code #include <iostream> using namespace std; int main(){ int x,y; char o;…
Q: Write a c program that ask user to insert continously until and then prints the count of even and…
A: Programming Approach: define the header file. using the main()method. declaring variables. the loop…
Q: Write a C that reads in 10 integen number and prints back those numbers revesed that can be divided…
A: Using for loops we can solve this problem.
Q: 3. Write a C++ program that find and print the value of Z, for the fallowing equations: x = 1 x + 2…
A: take values of x from user. apply if else to find value of z.
Q: Write a program in C++ language that reads three integers from the keyboard, then there is a cube…
A: #include<iostream> using namespace std; int main(){ int a,b,c,cube_a,cube_b,cube_c;…
Q: Fill the blank in a C program to Check whether a Number is Odd or Even using function void…
A: We need to find the correct answer from the given options for the given C language code. The program…
Q: Q.6 Write a C++ program that takes 6 values from user and makes a multiplication table of those…
A: The answer is...
Q: write a c++ program that asks user to enter a number and then print the number that is maximum time…
A: #include<iostream> using namespace std; int main(){ int n, x, max_count=0; cout…
Q: Write a Program in C++ programming language to take three ints, a b c, print if it is possible to…
A: Required: Write a Program in C++ programming language to take three ints, a b c, and print if it is…
Q: Write a C++ program that ask user to insert numbers continuously until and then prints the count of…
A: Solution with detail explanation using c++ comments:- #include <iostream> using namespace std;…
Q: Write a program in C to print reversed mirrored right triangle star patternt
A: Given: Write a program in C to print reversed mirrored right triangle star patternt
Q: Write a c++ program that will ask the user for number of terms N and base b, and then print the…
A: Program code: #include <iostream>using namespace std;int main(){ int trm, bs, r, q, i=1,…
Q: How many loops are there in C++? Examine the following loops: While and do while loops
A: There are three types of loops in C++ language: while-loop for-loop do-while loop The for-loop is…
Q: Write a program in C language to simulate tossing a “fair” coin. Allow the user to enter the number…
A: Write a program using c language that will take a number of tosses as input and find the number of…
Q: and stop when the sum of odd numbers equal to the sum of even numbers and then print their sum…
A: Write a c++ program to read a sequence of numbers and stop when the sum of odd numbers equal to the…
Reimplement the digital clock from the preceding exercise, representing the time as the minutes from midnight. This makes the pulse member function very easy, but you have to work harder to recover the hours and minutes. For example, 100 minutes after midnight is 1 hour and 40 minutes.
C++
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Consider the following class declaration and variable definitions, then answer the following questions. #include <stdio.h> class A { private: class B { public: B() { x = 1; } int x; int& getx() { return x; } void print() { printf(“%d”,x); } }; private: B b; public: class C { private: int w; public: C() { w = 5; } B b; int &getw() { return w; } void print() { b.print(); printf(“%d”,w); } }; C c; void print() { b.print(); c.print(); } int& getx() { return b.getx(); } }; Assume each code snippet in each row below runs independently in a main function. For each one, say whether it's legal code or not. If it is, show the output and explain why it happens. If it’s illegal (e.g. syntax error), explain why. Try to do it without running the code, and then check and correct your answers as needed. # Code snippet Errors? (Yes or No) Output or explanation of error. 1…Question: 3 write python program ; Implement the design of the Doctor and Engineer class derived from Person class so that the following code generates the output below:class Person: def __init__(self, name, contact): self.name = name self.contact = contact def __str__(self): s = f"Name: {self.name}\nContact: {self.contact}" return s#Write your code hered = Doctor("Dr Strange", "4585632", "Neurosurgery", "DMC")d.add_patients("Dhaka Abdur Rahim", "Dhaka John Cena", "Narayanganj John Wick", "Comilla CM Punk")print("1.=========================================================")print(d)print("2.=========================================================")d.show_patient_list("Dhaka")print("3.=========================================================")d.show_patient_list("Rajshahi")print("4.=========================================================")d.add_patients("Narayanganj Naruto…C++ Consider the following code: class A { public: virtual void printChar() { cout << 'A' << endl; } }; class B : public A { public: void printChar() { cout << 'B' << endl; } }; int main() { A a; B b; A *ptr; ptr = &a; ptr->printChar(); ptr = &b; ptr->printChar(); } Choose the best statement below: Consider the following code: class A { public: virtual void printChar() { cout << 'A' << endl; } }; class B : public A { public: void printChar() { cout << 'B' << endl; } }; int main() { A a; B b; A *ptr; ptr = &a; ptr->printChar(); ptr = &b; ptr->printChar(); } Choose the best statement below: a.) This code compiles, but has poor style. You shouldn't have a function printChar() defined in both classes. b.) This code compiles, and there is an example of polymorphism in the code. c.) This code compiles, and there is no example of…
- Using C++ 11 Write a program which overloads fractions arithmetic operations for division. And include the overloading operators which we did in the class like multiplication, comparison, insertion, and extraction operators. Here is the class: class NumDays { int hr; //declaring hour variable to store hours float days; //declaring days variable to store days public: //default constructor NumDays() { hr = 0; days = 0.0; }; // parametrized constructor NumDays(int hrs) { hr = hrs; days = float(hrs / 8.0); }; // implementing getters method to return hours value from class int getHour() { return hr; } // implementing getters method to return no of days from class float getDays() { return days; } // method to implement addition operator NumDays operator + (NumDays obj) { int hrs = getHour() + obj.getHour(); NumDays temp(hrs); return temp; } // method to…Computer Science In Java, create a class Die representing a die to roll randomly. -Give Die a public final static int FACES, representing how many faces all dice will have for this run of the program. -In a static block, choose a value for FACES that is randomly chosen from the options 4, 6, 8, 10, 12, and 20. -Give Die an instance variable current, representing the last value it rolled. (cannot be less than 1 or more than FACES) -Give Die int instance variables maxCount and minCount. (cannot be negative) -Give Die a method roll that randomly sets current to a value between 1 and FACES. If the die rolls a 1, increase minCount, if the die rolls FACES, increase maxCount. -Give Die a static method sumDice, which takes a variable length parameter list of Dies and returns the sum of all their current values. -Give Die a static method sameDice, which takes a variable length parameter list of Dies, and returns true only if all of them have the same current value. Do not compare…In Java - A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400; therefore, both 1700 and 1800 are not leap years Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Default code: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int inputYear; boolean isLeapYear; isLeapYear = false; inputYear = scnr.nextInt(); /* Type your code here. */ }}
- Consider the following code: class A { public: void printChar() { cout << 'A' << endl; } }; class B : public A { public: void printChar() { cout << 'B' << endl; } }; int main() { A a; B b; A *ptr; ptr = &a; ptr->printChar(); // line 1 ptr = &b; ptr->printChar(); // line 2 } Choose the best statement below: a. This code compiles, but has poor style. You shouldn't have a function printChar() defined in both classes. b. This code compiles, and there is an example of polymorphism in the code. c. This code compiles, and there is no example of polymorphism in the code. d. This code does not compile.(Use BigInteger for the Rational class) Redesign and implement the Ratio-nal class in Listing 13.13 using BigInteger for the numerator and denomina-tor. Write a test program that prompts the user to enter two rational numbers and display the results as shown in the following sample run: Enter the first rational number: 3 454Enter the second rational number: 7 2389 3/454 + 7/2389 = 10345/10846063/454 – 7/2389 = 3989/10846063/454 * 7/2389 = 21/10846063/454 / 7/2389 = 7167/31787/2389 is 0.0029300962745918793Computer Science Need Debugging following these guidelines: program produces correct output Fixed bug(s) in Car class // Creates a Car class // You can construct a Car using a price and color // or just a price, in which case a Car is black // or no parameters, in which case a Car is $10,000 and black using System; using static System.Console; using System.Globalization; class DebugNine3 { static void Main() { Car myCar = new Car(32000, "red"); Car yourCar = new Car(14000); Car theirCar; WriteLine("My {0} car cost {1}", myCar.color, myCarr.Price.ToString("c2", CultureInfo.GetCultureInfo("en-US"))); WriteLine("Your {0} car cost {1}", yourCar.Color, youRCar.price.Tostring("c2", CultureInfo.GetCultureInfo("en-US"))); WriteLine("Their {0} car cost {1}", theirCar.Color, theirCar.price.ToString("c2", CultureInfo.GetCultureInfo("en-US"))); } } class Car { private…
- Instructions-Java Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works. Next add the following public methods to the Address class and test them from main as you go: Write getters and…what is the output of the following codes : code 1. class A { { System.out.print(1); } } class B extends A { { System.out.print(2); } } class C extends B { { System.out.print(3); } } public class MainClass { public static void main(String[] args) { C c = new C(); } } code 2 class M { int i; public M(int i) { this.i = i--; } } class N extends M { public N(int i) { super(++i); System.out.println(i); } } public class MainClass { public static void main(String[] args) { N n = new N(26); } } code 3 class M { int i; public M(int i) { this.i = i--; } } class N extends M { public N(int i) { super(++i); System.out.println(i); } } public class MainClass { public static void main(String[] args) { N n = new N(26); } }Implement “SoftwareEngineer” and “CheifEngineer” class derived from “Employee” class with necessary properties so that the expected output is generated. Do not change any given code. # Write your codes here.# Do not change the following lines of code.sw1 = SoftwareEngineer("Bob","Software Engineer",40,1200)print('1.------------------------------------')sw1.calculateWeeklyIncome()print('2.------------------------------------')print(sw1)print('3.------------------------------------')sw2 = SoftwareEngineer("Carol","Software Engineer",45,1200,5)print('4.------------------------------------')sw2.calculateWeeklyIncome()print('5.------------------------------------')print(sw2)print('6.------------------------------------')print(Employee.employeeInfo)print('7.====================================')ce1 = ChiefEngineer("John","Chief…