Concept explainers
In the
that symbol = ‘7’;
System.out.printin((int) symbol);
Thus, (int) symbol does not produce the number corresponding to the digit in symbol. Can you write an expression that will work to produce the integer that intuitively corresponds to the digit in symbol, assuming that symbol contains one of the ten digits 0 through 9? (Hint: The digits do correspond to consecutive integers so if (int) ‘7’ is 55, then(int) ‘8’ is 56.)
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Absolute Java (6th Edition)
Modern Database Management
Introduction To Programming Using Visual Basic (11th Edition)
C Programming Language
Starting Out with Programming Logic and Design (4th Edition)
- What is the output of the following code segment?inte=5,f=10;if(eff0)Write(Purple) inte=5,f=10;if(eff0)Write(Purple) else Write(Gold); Purple Gold PurpleGold nothingarrow_forwardImplement the following:Given:food1 = "Salad"food2 = "Sandwich"price1 = 3.6price2 = 4.99 Print two f-string statements to display the following according to the rules below:1) Food prefixed with "Lunch:"2) Price prefixed with "Cost: $"3) Food always has 25 characters of space.4) Price is always displayed with two decimal places. Just make sure to precisely match the output format below.Write your code in the ANSWER area provided below (must include comments if using code is not covered in the course).Example OutputLunch: Salad Cost: $3.60Lunch: Sandwich Cost: $4.99arrow_forwardI need help writing a Java Code. Write a program that prompts the user to enter an integer for today's day of the week (Sunday is 0, Monday is 1, and Saturday is 6. Also, prompt the user to enter the number o days after today for a future day and display the future day of the week.arrow_forward
- Write a program named ConvertDate that converts a date entered by the user into another form. The user's input will have the form: month day, year The month will be one of the words January, February,... The letters in the month may be lowercase, uppercase, or any mixture of the two. The day is a one- or two-digit number. The year is any number of digits. There may be any number of spaces (1) before the month, (2) between the month and the day, (3) between the day and the year, and (4) after the year. You may assume that there is at least one space between the month and day and between the day and year. You may also assume that there is a comma after the day. The converted date must have the form day month year with one space between the day and month and between the month and year. The first letter of the month must be uppercase, and the remaining letters must be lowercase. The following example shows what the user will see on the screen: Enter date to be converted: apRiL 28, 2003…arrow_forwardWith your askForYesNo method, how would you get the same result with only using one if/else if/else statement?? (IN JAVA PROGRAMMING) You also need to fix up your styling: All your method comments need to be in a block comment (/** comment */) and should include the parameters taken and values returned All your variables need to have a line comment (//comment) next to them explaining what they are going to be used for import java.util.Scanner; /** * 4.3CR User Input Functions * a functions to read a number within a range, and read more natural boolean values from the user * * @author MEHAKPREET KAUR * @version 04/08/2021 */ public class UserInput { // method to diplay askForInt public static int askForInt(Scanner in, String ask, int min, int max){ int value; //value entered by user System.out.print(ask + "(" + min + "-" + max + "): "); value = in.nextInt(); //loop check for invalid value while(value < min || value > max){…arrow_forwardIn your favorite open world adventure video game, currency conversion is as given below: 1 Gold coin 23 Bolts 1 Gem 13 Gold coins Write a program that takes a number of Bolts as user input (as an integer) and converts it to the number of whole Gems, Gold coins, and Bolts as shown below. The conversion information between these measurement metrics is provided in the table above. The number of Bolts should be converted in such a way that maximizes the whole number of Gems and Gold coins. Expected output 1 (bold is user input) Enter the number of Bolts: 32 0 Gems(s) 1 Gold coin(s) 9 Bolt(s) Expected output 2 (bold is user input) Enter the number of Bolts: 3000 10 Gem(s) 0 Gold coin(s) 10 Bolt(s) The file should be named as convertCurrency.cpp. Don’t forget to head over to Coderunner on Canvas and paste your solution in the answer box!arrow_forward
- Write an application that prompts for and reads the numeratorand denominator of a fraction as integers and then prints the decimal equivalent of the fraction.arrow_forwardIN JAVA Complete the program below so that it prompts the user for a temperature value, followed by a character that represents the type of temperature: C for Celsius F for Farhenheit If the character represents Fahrenheit temperature (F), convert the temperature value to the equivalent value in Celsius, using the following formula:C = (5/9)(F - 32.0)where C represents the Celsius temperature value, and F represents the Farhenheit temperature value. If the character represents Celsius temperature (C), convert the temperature value to the equivalent value in Farhenheit, using the following formula: F = (9/5)C + 32.0arrow_forwardCORAL HELP Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. End each line with a newline. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is: 0 or less than 0, the output is: no change Ex: If the input is: 45 the output is: 1 quarter 2 dimesarrow_forward
- You are given an integer variable dollarAmount that will have an integer value of ten or larger. It is a value that we want to display on a check. In order to write out the amount in words, the first step is to determine the digit from the ones position and from tens position. We are going to take those first steps! Declare an integer variable named ones and initialize it to the value in the ones position from dollarAmount. Declare an integer variable named tens and initialize it to the value in the tens position from dollarAmount. Declare an integer variable named hundreds and initialize it to the value in the hundreds position from dollarAmount. e.g. If dollarAmount = 1729,we would expect ones = 9, and tens = 2, and hundreds = 7. Sample input/output: Input Output 1729 Ones: 9 Tens: 2 Hundreds: 7 19452 Ones: 2 Tens: 5 Hundreds: 4 Output has been taken care of for you.arrow_forwardWrite a program that calculates the estimated hours and minutes for a trip given the number of miles traveled and the speed in miles per hour. Specifically, write a program that Welcomes the user to the Travel Time Calculator. Asks user for number of miles traveled(allow user to enter fractional values) Asks user for the speed in miles per hour (allow user to enter fractional values) Calculates the number of hours and minutes for the trip to the nearest integer value. Hint: You can use the built-in function round that rounds a given number to the rounded integer value. e.g. round(4) will return 4, round(4.125) will return 4, round(4.5) will return 4 and round (4.75) will return 5. Prints the number of hours and minutes for the trip. Here are some sample runs:arrow_forwardthis assignment wants me to: Convert the QuartsToGallons program to an interactive application. Instead of assigning a value to the number of quarts, accept the value from the user as input. my code is . it is saying that they can not find symbol in quartsNeeded=input.NextInt(); final int QUARTS_IN_GALLON = 4; int quartsNeeded = 18; int gallonsNeeded; int extraQuartsNeeded; Scanner input = new Scanner(System.in); System.out.print("Enter quarts >>"); quartsNeeded = input.NextInt(); gallonsNeeded = quartsNeeded / QUARTS_IN_GALLON; extraQuartsNeeded = quartsNeeded % QUARTS_IN_GALLON; System.out.println("A job that needs " + quartsNeeded + " quarts requires " + gallonsNeeded + " gallons plus " + extraQuartsNeeded + " quarts.");arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,