int num = 123; int num2 = num / 10; int num3 = num2 / 10; int num4 = num num3 * 100; int num5 num4 / 10; int num6 = num4 num5 * 10; num5 = num * 1000 + (num6 * 100 + num5 * 10 + num3);
Q: Date -day: int -month: int -year:int +getDay():int +getMonth(): int +getYear(): int +setDay(Day:…
A: Include Header files. Create class Date. Class Date has Data member day, month, and year as…
Q: Java Program 1. JA’s GYM Equipment rents gym equipment such as dumbbell, kettlebell, Treadmill,…
A: logic:- read number of minutes from user. Get number of hours=minutes/60 calculate remaining…
Q: Finish the method called countAppearance() that will take String [] and String arguments and return…
A: Java is the object oriented programming language that can be used to create the application. We can…
Q: int s-16; int k-1; for (int i-e; i<5; i++) for(int j=0; j<s; j++) printf(" "); S=s-4; for (int j-e;…
A: Correct Option - Option 3
Q: Given two integers as user inputs that represent the number of drinks to buy and the number of…
A: SOLUTION-I have solve the problem in C++ code and screenshot for understanding :) CODE- main.cpp…
Q: JAVA Programming Problem 5 – CharacterArray Write a program which will store the following string…
A: i wll provide two solutions for this question public class CharacterArray {public static void…
Q: Determine the value ranges that may be represented by the following data types
A: The data type is an attribute that tells what kind of data that value can have. These are used for…
Q: int i, temp[10]; for (i = 0; i< 10; i++) temp[i] = 2*i; for (į = 0; į < 10; i++) cout << temp[) << "…
A: Given code: #include <iostream>using namespace std;int main(){ int i,temp[10]; for(i =…
Q: int main (void) int base, height; printf("Enter the base of the triangle:",base); //Input the base…
A: In this question, we have given a C code. We just need to explain the code in simple words. The…
Q: java a. Four integer variables have been declared and initialized: p1, p2, p3, and p4. You need to…
A: The given question is from JAVA language. In the first part we have to add the missing statement,…
Q: 1. The circle has two data members, a Point representing the center of the circle and a float value…
A: #include<stdio.h>#include<math.h> typedef struct{ float x; float y;}Point; typedef…
Q: Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Assign userNum2 with 4…
A: 1. Take two inputs from the user. 2. Write the if condition for userNum1. 3. Write the if condition…
Q: es = new int[2][8]; es = new int[4][4];
A: Declaring array syntax Data_type arrayName [ arraySize ]; Data_type is the type of data in array…
Q: public class IncrementDecrement { public static void main (String[] args) { int number = 50; int…
A: Given: Run the following code. Write its output and also explain the output
Q: In Java scripts A number is called a Disarium when the sum of its digits in their respective order…
A: Algorithm - create a new method with one argument n. Now create a variable to store the number and…
Q: 5. pointers, structs and arrays Given the definition struct Animal { char * species; int age; }; and…
A: Given: Goal: We have to describe in words about the above three struct declarations
Q: class Fraction private int num, denom; public Fraction(int num, int denom) (/code elided"/> public…
A: A fraction is a ratio of two values. The fraction has the form a / b where a is called the…
Q: /* (Generate vehicle plate numbers) Assume a vehicle plate number consists of three uppercase…
A: this program uses random module , Math.random() generate random number . upper case letter in…
Q: eads three nonzero values entered by the user and determines and prints whether they could represent…
A: Summary Method 1 if the first side is greater than or equal to the sum of the alternate and the…
Q: Java I am beginner in java my program is to take 2 number from user and given that these number is…
A: Approach :- take two numbers from user using scanner object and then print the remainder using…
Q: Population Count Description: The population count is the number of 1s (ones) in the binary…
A: The answer is given below.
Q: void fact(int num) { int k,f=1; for (k=1;k<=num; k++) f=f*k; cout<< f; int main() { int…
A: Given:
Q: Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum…
A: PROGRAM INTRODUCTION: Import the required header files. Start the definition of the main function.…
Q: #import math library #define functions #return type: float #Parameters: 2 floats(l and w) #This…
A: #import math libraryimport math#define functions #return type: float#Parameters: 2 floats(l and…
Q: Used Java 4.23 (Financial application: payroll) Write a program that reads the following information…
A: We need to develop a program as per the given logic. Programming Language : Java As required, the…
Q: Write a program that plays a number-guessing game to guess a secret number randomly generated within…
A: // Java program for the above approach import java.util.Scanner; public class GuessingGame { //…
Q: q1) provide commneted code for each line of code
A: I have given the whole code with proper comments so that you can understand it well. Hope it will…
Q: struct ID { int x; int y; }; struct name { ID r; }; int main() { name a[2]; for (int i=0;i<2;i++) {…
A: Given code is struct ID { int x; int y; }; struct name {ID r; }; int main() { name a[2]; for(int…
Q: a) b) C) d) CO 1 123 2 4 5 6 7 8 9 10 11 12 20 19 TELE 345 13 #include #include int main(){ 14 15…
A:
Q: (b) #include int main() { int a, b; a = -3 -- 3; b = -3 -- (-3); printf ( "a = %d b = %d\n", a, b )…
A: The code is having following errors which are listed below:
Q: This program assigns values to two variables // and performs mathematical operations with them
A: Errors 1. System.out.println("adding " + x + y); The above statement concatenates the value of x and…
Q: * iii. This program calculates the driving skill and points of two players in a driving game. *…
A: Total code is in the final step from start to end. This method is use to take the input we can use…
Q: (Same-number subsequence) JAVA Class Name: Exercise22_05 Write an O(n) program that prompts the…
A: Java program: import java.util.Scanner; public class Main { public static void main(String[] args) {…
Q: 2 ii) int a = 5; //L1 //L2 5; i <= 6; i++) for (int i { а %3D а + 3; System.out.println(a); } a = a…
A: In this question, we are given a java language code. And we have to trace it and find out the…
Q: #include using namespace std; int Compute (int vall, int val2) { int result = 0; %3D int i; for (i…
A: The answer to the given question: This is a c++ program, In this particular program, the main…
Q: 7 #include #include using namespace std; int val (char c) 11 E { 8 9 10 if (c >= '0' && c = 'A' &&…
A: This is c code written in C++ form
Q: Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum…
A: Hey, since multiple questions posted, we will answer first question according to our policy. If you…
Q: void func1(int&); void func2(int&, int&); void func3(int, int); eint main(){ int x = 0, y = 0, z =…
A: Introduction of the Program: The C++ program is an example of pass by reference where the reference…
Q: Write two short programs explaining data encapsulation in java
A: Java is a pure object-oriented programming language(OOPS) in which OOPs provide many features such…
Q: int temp=2; void cloudy (int u=3, int v=4) { V = u; u = v - temp; } void main() { int num1 = 6; int…
A: answer is 6 10 2 explanation: initial values of num1=6 and num2=10 we passed num2 as an argument…
Q: Population Count Description: The population count is the number of 1s (ones) in the binary…
A: A binary number is defined as a number that is expressed in the binary system or base 2 numeral…
Q: Java programming pls A complex number is a number in the form a+bi, where a and b are real numbers…
A: I give the code and output and code screenshot as well in java(As u asked). kindly refer to it as…
Q: Used Java 4.23 (Financial application: payroll) Write a program that reads the following information…
A: The program would have the following 4 sections:The declaration and initialization of the variables…
Q: void fun(int i) { do { if (i % 2 != 0) cout = 1); 1. cout << endl; } int main() { int i= 1;
A: Here C++ Code is given, output for the code is given below.
Q: Find the error(s) in the following code snippet and explain how to correct it (them): 1 class…
A: The function prototype of getIncrementedData is : int getIncrementedData() const {} which makes is…
Q: 2 iii) int a = 5; //L1 //L2 for(int i = 5; i <= 6; i++) { а %3D а + 3; System.out.println(a); //L3…
A: Given: \
Q: Date int month : int int day : int int year : int + Date (): void + Date(int aMonth, int aDay,int…
A: We have given UML class diagram. It has some attributes and methods. We have to convert the UML…
Q: Question Language: JAVA Keep Guessing Write a program that plays a number-guessing game to guess a…
A: Import the required java libraries. In main an object of the Random class has been created as r. In…
Q: import java.util.Scanner ; //This program enables the user enters 10 int between -100 and 100 //then…
A: After fixing the code, I have provided JAVA CODE along with CODE SCREENSHOT and 2 OUTPUT…
Q: 1 int computeArithmeticProgression(int num) 0; 2 int sum = 3 for (int i = 1; i <= num; i++) {
A: Given:
Given the following code segment, what will be the value of the variable "num5" after executing the 7th statement? If an error occurs, indicate “error”
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- class Calculator: # Type your code here. if __name__ == "__main__": calc = Calculator(); num1 = float(input()) num2 = float(input()) # 1. The initial value print('{:.1f}'.format(calc.get_value())) # 2. The The value after adding num1 calc.add(num1) print('{:.1f}'.format(calc.get_value())) # 3. The value after multiplying by 3 calc.multiply(3) print('{:.1f}'.format(calc.get_value())) # 4. The value after subtracting num2 calc.subtract(num2) print('{:.1f}'.format(calc.get_value())) # 5. The value after dividing by 2 calc.divide(2) print('{:.1f}'.format(calc.get_value())) # 6. The value after calling the clear() method calc.clear() print('{:.1f}'.format(calc.get_value()))Time This class is going to represent a 24-hour cycle clock time. That means 0:0:0 (Hour:Minute:Second) is the beginning of a day and 23:59:59 is the end of the day. This class has these data members. int sec int min int hourmport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…
- Java programming pls A complex number is a number in the form a+bi, where a and b are real numbers and i is √(-1) The numbers a and b are known as the real part and imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas: a + bi + c + di = (a+c) + (b+d)i (addition) a + bi − (c + di) = (a−c) + (b−d)i (subtraction) (a + bi) * (c + di) = (ac−bd) + (bc+ad)i (multiplication) (a + bi) / (c + di) = (ac+bd) / (c2+d2) + (bc−ad)i / (c2+d2) (division) You can obtain the Absolute Value for a complex number using the following formula: |a + bi| = √(a2 + b2) A Complex number can be interpreted as a point on a plane by identifying the (a,b) values as the coordinates of the point. The absolute value of the complex number corresponds to the distance of the point to the origin, as shown in the example below. (1) Design a class named Complex for representing…Declare three structs: Struct TravelInfo{ String name; Double weight; Double newWeight; Int planetChoice; Int speed; }; Struct TravelTimeCalc{ Int totalTravelTime; Int years; Int days; Int hours; }; Struct Planet{ String planetNames; Double distanceFromSun; Double gravity; }; Planets, distance from sun(millions of miles), surface gravity as a percent of earth’s gravity: Mercury 36 0.27 Venus 67 0.86 Earth 93 1.00 Mars 141 0.37 Jupiter 483 2.64 Saturn 886 1.17 Uranus 1782 0.92 Neptune 2793 1.44 Pass the arrays to the FillPlanetInfo function that will load the data into the three arrays. Start a do while loop in main Pass the function AskSpaceTravellerInfo a reference to the TravelerInfo struct variable and the array of planet names. Get the user’s name, Earth weight, the speed they want to travel and the planet they wish to visit. Provide a menu with the planet names and a way for the user to select the chosen destination. Pass the data you obtained…In GO language. Create a struct that has student name, id, and GPA. Write functions to create a student, modify the student’s id, and modify the student's GPA, and print the student’s information. (This is like creating a class and methods). Now create an array of three students and test your functions. You may hardcode your values if using a web conpiler. (Please hardcode the values!)
- JAVA LANGUAGE Body Mass Index Version 2.0 by CodeChum Admin Recall that according to the National Heart, Lung, and Blood Institute of the National Institutes of Health, body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is used to monitor one's health by determining whether one is underweight, overweight, has normal weight or is obese. It is computed based as follows (when using standard weight in pounds and height in inches): BMI = 703 x (weight/(height2)) Furthermore, people with BMI scores that are less than 18.5 are said to be underweight. Those with scores between 18.5–24.9 (inclusive) are of normal weight. Those with scores between 25–29.9 (inclusive) are said to be overweight. And those with scores 30 or higher are obese. Input The input is composed of two positive integers representing the weight in pounds and the height in inches. 140·65 Output A single line containing two values: the computed…Language: JAVA Script Your company is giving every employee earning less than $50,000 a 10% raise! *Write a function 'employeeRaises(peopleObj)' that takes an array of objects s containing employee names and their salaries and returns an array containing the employees that need raises, along with their new salaries. Example: employees [ {name: "Alice", salary: 80000}, {name: "Bob", salary: 48000 }, {name: "Carol", salary: 60000}, {name: "Dan", salary: 78000}, {name: "Ellen", salary: 100000}, console.log(employeeRaises (employees) ); // [ { name: 'Bob', salary: 44000 } ] funcation emplyeeRaises(employees){ |// Your code here} /****DO NOT MODIFY ANYTHING UNDER THIS LINE****/ try{| module.exports = employeeRaises;}catch (e) {|module.exports=null;}(Java) The greatest common divisor of two positive whole numbers and n1 and n2 is the largest number g such that g evenly divided into both n1 and n2. Write a complete program that takes two positive whole numbers from the user and displays the common divisor.
- Transcribed Image Text JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2Assignment Write a program that moves a forester unit and a desert corps unit to a given target location and prints the number of hours it took for each unit to reach the target. First, the user will give the starting X and Y positions of the forester unit as well as its base speed (all ints). Then, the starting X and Y positions of the desert corps unit as well as its base speed (all ints). Finally, the target X and Y positions (both ints) and the terrain type (std::string). Speeds are given as distance traveled in one full day (i.e., 24 hours) and is affected by the terrain type using a multiplier over the base speed. Also, after 1 full day, each unit rests for a certain number of hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as below. Speed Multiplier Rest Duration After 1 day Terrain type Forester Desert Corps Forester Desert Corps Forest 1.3 0.6 4 12 Desert 0.4 1.2 15 6 Hills 0.7 0.8 6 8 Others 1.0 0.8 8 6 After getting all this…Explain following code segment:int [] a = new int [3];int [] b = new int [3];a = b;