Concept explainers
Given the following fragment that purports to convert from degrees Celsius to degrees Fahrenheit, answer the following questions:
a. What value is assigned to fahrenheit?
b. Explain what is actually happening, and what the programmer likely wanted.
c. Rewrite the code as the programmer intended.
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Concepts of Programming Languages (11th Edition)
Modern Database Management (12th Edition)
Digital Fundamentals (11th Edition)
Starting Out with C++: Early Objects
Starting Out with Java: From Control Structures through Objects (6th Edition)
- Choose the best data type for each of the following, so that no memory storage is wasted. Give an example of a typical value that would be held by the variable, and explain why you chose the type you did. the number of years of school you have completed your final grade in this class the population of China the number of passengers on an airline flight one players score in a Scrabble game the number of Electoral College votes received by a U.S. presidential candidate the number of days with below freezing temperatures in a winter in Miami, Florida one teams score in a Major League Baseball gamearrow_forwardCalculate and return the sum of two decimal numbers - getSum. Given the radius of a circle, print the area of a circle - printArea. Given a student’s name and three test scores (of type int), print the student’s name and average test score - printStudentDetails. Compute and return the average speed of a car, given the distance traveled (as type double) and traveling time (in hours and minutes, both of type int) - getAverageSpeed. *arrow_forwardThis is a debugging problem that I am completely stuck on. This is the question - The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. This is the code - // DebugFive1 // Adds your lunch bill // Burger and hot dog are $2.59 // Grilled cheese and fish are $1.99 // Fries are 89 cents import java.util.*; public class DebugFive1 { public static void main(String args[]) { Scanner input = new Scanner(System.in); final double HIGH_PRICE = 2.59; final double MED_PRICE = 1.99; final double LOW_PRICE = 0.89; String usersChoiceString; int usersChoice; double bill; System.out.println("Order please\n1 - Burger\n2 - Hotdog" + "\n3 - Grilled cheese\n4 - Fish sandwich"); usersChoiceString = input.next(); usersChoice == Integer.parseInt(usersChoiceString);…arrow_forward
- Here is the question: The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. Here is the code given: // Program prompts user to enter a series of integers // separated by spaces // Program converts them to numbers and sums them import java.util.*; public class DebugSeven2 { public static void main(String[] args) { String str; int x; int length; int start; int num; int lastSpace = -1; int sum = 0; String partStr; Scanner in = new Scanner(System.in); System.out.print("Enter a series of integers separated by spaces >> "); str = in.nextLine(); length = str.length(); for(x = 0; x <= length; ++x) { if(str.charAt(x) == ' ') { partStr = str.substring(lastSpace + 1); num =…arrow_forwardPlease do this in Python Programming and provide Screenshots The output should be exact same like in the examples. If the output in the example is in 2 decimals, then it should be like that. 1c - Othello 1 Othello, is a 2-player deterministic (no use of dice), perfect information (no information only known to one of the players) board game, similar to chess or go. The goal of this assignment is to give some information about the outcome once an Othello game has finished. This information is obtained by two measurements: The percentage of black pieces of all the pieces on the board. The percentage of the board that is covered in black pieces. The Othello board measures eight squares by eight squares, making the total number of squares sixty-four. Write a program that takes the number of white pieces followed by the number of black pieces as input. Print the two percentages as output. Enter the number of white pieces on the board: 34Enter the number of black pieces on the board:…arrow_forwardWrite a program to calculate the surface area and volume of a square pyramid. A square pyramid has a base that is square and all triangle faces are congruent isosceles triangles. (An isosceles triangle is a triangle in which two of the sides are equal. Length of the base: a Height of the pyramid: h Volume = a2h/3 Slant height, s = sqrt(h2 + (a/2)2) This is the Pythagorean Theorem part. Area of one pyramid side = s*a/2 For this program you are to determine two things about a square pyramid. 1) the surface area of the four sides. 2) the volume. Do not include surface area of the base. Test case 1: Height: 5.0' Base: 2.5' Test case 2: Height 2.5 Base: 4.3' The program asks the user to enter the pyramid height (in feet) and length of the base (in feet). Your program will need to determine surface area, and volume by using pythagorean theorem. Your output should neatly show the height, base, total surface area, and volume of the pyramid using 33 decimal place of…arrow_forward
- you are required to write a universal calculator that HALFs that value of the different types of data. Especially, the calculator must take the following types of input.1. a decimal number2. a float point number3. a binary number which must be prefixed with "0b" (e.g. 0b111, 0b1010 are valid. 01b1010, ob101, 01010 are invalid)4. a hexadecimal number which must be prefixed with "0x" (e.g. 0x19, 0xAA are valid. 01x1A, ox1A, 01A are invalid) Please note that:Your program must implement function overloading. You can consider the examples below for your implementation. You are provided with the initial code which can be found. The initial code has already checked different types of input for you.arrow_forwardYou can find out how many seconds have elapsed since Jan 1, 1970 using the time() function. #include <time.h> now = time(NULL); // now is more than a billion seconds (which data type should you use?) Write a program that estimates how many years, months, weeks, days, and hours have gone by since Jan 1 1970 by calculations with the number of seconds that have passed. The number of months must be less than 12, i.e., take out how many years have gone by first, then how many months are left, then weeks, etc. Assume that all years have 365 days, and all months have 30.42 days. Don’t use a calculator, or any web site that reports the number of seconds in a month, etc. – your C program can calculate anything that you need. Notice that this is an assignment on using arithmetic in C. Hints. How many seconds are in a minute? hour? A day? A week? A month? A year?arrow_forwardHello, I am coding in Python 3 and was given this assignment, I currently have no idea where to start and Pseudocode for this problem would be extremely helpful. Kevin and Stacy want to play a game they have titled 'Vowels or Not?'. Here are the game rules: Both players are given the same string, S. Both players have to make substrings using the letters of the string S. Kevin has to make substrings starting with consonants. Stacy has to make substrings starting with vowels. (Note: vowels are only defined as AEIOU, i.e., in this game, Y is not considered a vowel.) The game ends when both players have made all possible substrings. A player gets +1 point for each occurrence of the substring in the string S. For example, consider the string S= BANANA. Suppose Stacy's vowel beginning substring is ANA. In this case, ANA occurs twice in BANANA. Hence, Stacy will get 2 points for this substring. See the following figure for other examples. Your task is to determine the winner of the game…arrow_forward
- Can you please help me answer the following question? Thank you ! Program is Python. def area(side1, side2): return side1 * side2 s1 = 12 s2 = 6 Identify the statements that correctly call the area function. Select ALL that apply. Question options: a) answer = area(s1,s2) b) result = area(side1side2) c) print(f'The area is{area(s1,s2)}') d) area(s1,s2)arrow_forwardGiven three int variables that have been given values, areaCode, exchange, and lastFour, write a string expression whose value is the string equivalent of each these variables joined by a single hyphen (-) So if areaCode, exchange, and lastFour, had the values 800, 555, and 1212, the expression's value would be "800-555-1212". Alternatively, if areaCode, exchange, and lastFour, had the values 212, 867 and 5309 the expression's value would be "212-867-5309".arrow_forwardHi, I need help with the following assignment. Implement a program that reads in a year and outputs the approximate value of a Ferrari 250 GTO in that year. Use the following table that describes the estimated value of a GTO at different times since 1962. Year Value 1962-1964 $18,500 1965-1968 $6,000 1969-1971 $12,000 1972-1975 $48,000 1976-1980 $200,000 1981-1985 $650,000 1986-2012 $35,000,000 2013-2014 $52,000,000arrow_forward
- 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++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr