Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 2.5, Problem 2.23CP
Explanation of Solution
Given statements:
double portion;
portion = 70/3;
The division statement in the above given statements is an example of integer division.
- After the division process, the 23.0 will be stored in the variable “portion”...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Is the following an example of integer division or floating-point division? Whatvalue will be stored in portion ?portion = 70 / 3;
Teacher has prepared the result of a class containing n number of students. He wants to
give the award to 3 toppers of the class. Display the Result for 3 toppers as reflected as percentage
form in floating type data.
Note- include class in code and write the code in C++.
Please do this question .
Please include class in this code
1. What is the purpose of the new operator?
2. True/False: if you use the new operator, you later should use delete. Why or why not?
3. True/False: When you add 1 to a pointer using the ++ operator, you are actually adding the size of the data type referenced by the pointer
4. You are reading a program which includes the following lines:
int size = 5;int *cards = new int[size];
Which of the below statements is true:
a) int *cards is a function to print cards
b) If there is no delete statement anywhere else in this program, this program has a memory leak.
c) The program won’t compile if there is no delete statement elsewhere in this program.
d) None of the above
Chapter 2 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 2.1 - Prob. 2.1CPCh. 2.1 - When the program in Question 2.1 is saved to a...Ch. 2.1 - Complete the following program skeleton so it...Ch. 2.1 - On paper, write a program that will display your...Ch. 2.1 - Prob. 2.5CPCh. 2.1 - Every Java application program must have...Ch. 2.2 - The following program will not compile because the...Ch. 2.2 - Study the following program and show what it will...Ch. 2.2 - On paper, write a program that will display your...Ch. 2.3 - Examine the following program. // This program...
Ch. 2.3 - What will the following program display on the...Ch. 2.4 - Which of the following are illegal variable names...Ch. 2.4 - Prob. 2.13CPCh. 2.4 - Prob. 2.14CPCh. 2.4 - Prob. 2.15CPCh. 2.4 - A program declares a float variable named number,...Ch. 2.4 - Prob. 2.17CPCh. 2.4 - Prob. 2.18CPCh. 2.4 - Prob. 2.19CPCh. 2.4 - Prob. 2.20CPCh. 2.4 - What is wrong with the following statement? char...Ch. 2.5 - Prob. 2.22CPCh. 2.5 - Prob. 2.23CPCh. 2.6 - Write statements using combined assignment...Ch. 2.7 - The following declaration appears in a program:...Ch. 2.7 - The variable a is a float and the variable b is a...Ch. 2.9 - Write a statement that declares a String variable...Ch. 2.9 - Assume that stringLength is an int variable. Write...Ch. 2.9 - Prob. 2.29CPCh. 2.9 - Prob. 2.30CPCh. 2.9 - Prob. 2.31CPCh. 2.11 - Prob. 2.32CPCh. 2.11 - How are documentation comments different from...Ch. 2.14 - Prob. 2.34CPCh. 2.14 - Write code that will display each of the dialog...Ch. 2.14 - Write code that displays an input dialog asking...Ch. 2.14 - Prob. 2.37CPCh. 2 - Every complete statement ends with a __________....Ch. 2 - The following data 72 'A' Hello World 2.8712 are...Ch. 2 - A group of statements, such as the contents of a...Ch. 2 - Which of the following are not valid assignment...Ch. 2 - Which of the following are nor valid println...Ch. 2 - The negation operator is __________. a. unary b....Ch. 2 - This key word is used to declare a named constant....Ch. 2 - These characters mark the beginning of a...Ch. 2 - These characters mark the beginning of a...Ch. 2 - These characters mark the beginning of a...Ch. 2 - Which Scanner class method would you use to read a...Ch. 2 - Which Scanner class method would you use to read a...Ch. 2 - You can use this class to display dialog boxes. a....Ch. 2 - Prob. 14MCCh. 2 - Prob. 15MCCh. 2 - True or False: A left brace in a Java program is...Ch. 2 - True or False: A variable must be declared before...Ch. 2 - True or False: Variable names may begin with a...Ch. 2 - True or False: You cannot change the value of a...Ch. 2 - True or False: Comments that begin with / / can be...Ch. 2 - True or False: If one of an operators operands is...Ch. 2 - What will the following code segments print on the...Ch. 2 - int x = 0, y=2; x = y 4; System.out.println(x +...Ch. 2 - System.out.print(I am the incredible);...Ch. 2 - System.out.print(Be careful\n);...Ch. 2 - int a, x = 23; a = x % 2; System.out.println(x +...Ch. 2 - Find the Error There are a number of syntax errors...Ch. 2 - Show how the double variables temp, weight, and...Ch. 2 - Prob. 2AWCh. 2 - Write assignment statements that perform the...Ch. 2 - Assume the variables result, w, x, y, and z are...Ch. 2 - Prob. 5AWCh. 2 - Modify the following program so it prints two...Ch. 2 - What will the following code output? int apples =...Ch. 2 - What will the following code output? double d =...Ch. 2 - What will the following code output? String...Ch. 2 - What will the following code output? String...Ch. 2 - Convert the following pseudocode to Java code. Be...Ch. 2 - Prob. 12AWCh. 2 - Write the code to set up all the necessary objects...Ch. 2 - Prob. 14AWCh. 2 - A program has a float variable named total and a...Ch. 2 - Is the following comment a single-line style...Ch. 2 - Is the following comment a single-line style...Ch. 2 - Describe what the phrase self-documenting program...Ch. 2 - Prob. 4SACh. 2 - Prob. 5SACh. 2 - Prob. 6SACh. 2 - Prob. 7SACh. 2 - Prob. 8SACh. 2 - Briefly describe the difference between variable...Ch. 2 - What is the difference between comments that start...Ch. 2 - Briefly describe what programming style means. Why...Ch. 2 - Assume that a program uses the named constant PI...Ch. 2 - Assume the file Sales Average, java is a Java...Ch. 2 - Prob. 14SACh. 2 - Name, Age, and Annual Income Write a program that...Ch. 2 - Name and Initials Write a program that has the...Ch. 2 - Personal Information Write a program that displays...Ch. 2 - Star Pattern Write a program that displays the...Ch. 2 - Sales Prediction The East Coast sales division of...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Sales Tax Write a program that will ask the user...Ch. 2 - Cookie Calories A bag of cookies holds 40 cookies....Ch. 2 - Miles-per-Gallon A cars miles-per-gallon (MPG) can...Ch. 2 - Test Average Write a program that asks the user to...Ch. 2 - Circuit Board Profit An electronics company sells...Ch. 2 - Prob. 12PCCh. 2 - Restaurant Bill Write a program that computes the...Ch. 2 - Male and Female Percentages Write a program that...Ch. 2 - Stock Commission Kathryn bought 600 shares of...Ch. 2 - Energy Drink Consumption A soft drink company...Ch. 2 - Ingredient Adjuster A cookie recipe calls for the...Ch. 2 - Word Game Write a program that plays a word game...Ch. 2 - Stock Transaction Program Last month Joe purchased...Ch. 2 - Planting Grapevines A vineyard owner is planting...Ch. 2 - Compound Interest When a bank account pays...
Knowledge Booster
Similar questions
- Write a function called sumSeries that computes the following summation:?(?) =1/2 +2/3+....+i/(i+1)Write a test program that uses sumSeries to display the following table:i m(i)1 0.50002 1.1667…19 16.402320 17.3546arrow_forwardTeacher has prepared the result of a class containing n number of students. He wants to give the award to 3 toppers of the class. Display the Result for 3 toppers as reflected as percentage form in floating type data Note- Please write a new code in C++arrow_forwardc++ int * board; int rows; int columns; cout << "Line 4: Enter two numbers:\n"; cin >> columns >> rows; cout << endl; board= new int [rows]; for (int row =0; row < rows; row++) board [row] = new int [columns]; Question: Given the following INPUT: 2 3 10 20 30 40 If the data was entered was as noted in the code the code above, WHAT would be the declaration of be if it were not dynamically allocated?arrow_forward
- You are creating a function that manipulates a number. The function has the following requirements:-> A float is passed into the function-> The function must take the absolute value of the float-> Any decimal points after the integer must be removedWhich two math functions should you use? Each correct answer is part of the solution. (Choose two.) Group of answer choices math.floor(x) math.frexp(x) math.ceil(x) math.fmod(x) math.fabs(x)arrow_forwardThe Middletown Wholesale Copper Wire Company sells spools ofcopper wiring for $100 each and ships them for $10 apiece. Write aprogram that displays the status of an order. It should use twofunctions. The first function asks for the following data and storesthe input values in reference parameters.The number of spools ordered.The number of spools in stock.Any special shipping and handling charges (above the regular$10 rate).arrow_forwardThe following is the difference between void and NULL pointers: Use relevant examples to back up your statement.arrow_forward
- Which of the following C# types cannot contain floating-point numbers? a. float b. double c. decimal d. intarrow_forwardWhich function does not return the pointer correctly?The code below calls the getline member function of cin to read a line of characters from cin into an array of characters up to a certain limit specified as the second parameter of the call.Your job is to find out if the pointer returned from the function can still be used by the caller of the function to access the memory that is pointed to by the pointer.char *getName() { char buf[80]; cout << "Enter your name: "; cin.getline(buf, 80); return buf;}char *getName() { char buf[80]; cout << "Enter your name: "; cin.getline(buf, 80); return buf;}char *getName() { char *buf = new char[80]; cout << "Enter your name: ";cin.getline(buf, 80); return buf;}None of thesechar getName(char buf, int size) { **cout << "Enter your name: ";cin.getline(buf, size);return buf;}arrow_forwardCreate a function called surprise_function () which takes in two integers and adds them together. You will then create the following overloaded versions, which should do different things based on the data type passed in: Data Type Operation Integer Addition Float Division Double Modulus Char Concatenation (Return as String) Boolean Result of AND You should prompt the user for what data type they want to enter, then ask for two values of that data type. Then, call surprise_function (), pass in the values, store the result in an appropriate variable, then print the variable. Note: You must make overloaded functions for this assignment – they must all be called surprise_function (). You can not create unique, non-overloaded functions like surprise_function_booleans(). Dynamic Arrays for C++ . There are several popular compilers, but there are a few key differences between what they will and won’t allow you to do in C++. In some compilers, the following code is…arrow_forward
- In Cpp, Write a program that: Defines an enum named Scoops. The enum Scoops will have 3 data values: single, double, and tripple. Define variables needed for customer name, ice cream flavor, and number of scoops. Reads the value of the customer name, ice cream, and number of scoops from the user. Use a switch statement and the following price chart to determine the price: 1 scope = $3.75 2 scopes = $5.50 3 scopes = $7.20 Prints customer name, price of order based on scoop, and flavor of ice cream ordered.arrow_forwardQuestion 1 is already done need help with the others though This is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees **emps = new employees()[10]; //Added new statement ---- bartleby // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for(int i =0; i <9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to…arrow_forwardStream manipulator showpoint forces floating-point values to print with the default sixdigits of precision unless the precision value has been changed, in which case floatingpoint values print with the specified precision. T/Farrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,