Question

In: Computer Science

Provide a formatted printing statement that yields $▯▯323.500 for input 323.5. Note that ▯ means a...

Provide a formatted printing statement that yields $▯▯323.500 for input 323.5. Note that ▯ means a space.

Solutions

Expert Solution

Formatted Printing Statement: Formatted input/output us very portable. It is a simple process to move formatted data files to various computers,even computers running different operating systems, as long as they all use the ASCII character set ( ASCII is the American Standard Code for Information Interchange , It is the character set used by almost all current computers with the notable exception of large IBM mainframes). Formatted files are human readable and can be typed to the terminal screen or edited with a text editor.

There are several ways to present the output, data can be printed in a human-readable form or written to a file for future use. Sometimes user often wants more control the formatting of output that simply printing space seperated values.

Formatted printing statement in python:

print("$  %5.3f"%(323.5))

You can also take the value from keyword and then replace 323.5 by the value provided by the user.

Here 5

%5.3f is used to represent that it is decimal number.

If we use %5.2f then the outpur is $ 323.50

If we use %5.4f then the outpur is $ 323.5000


Related Solutions

IN JAVA PLEASE!!! Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior....
IN JAVA PLEASE!!! Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input. (1) Create an ItemToPurchase class per the following specifications: Private fields Create a default constructor string itemName - Initialized in default constructor to "none" float itemPrice - Initialized in default constructor to 0.0 int...
Is there a difference in the yields of different types of​investments? The accompanying data provide yields...
Is there a difference in the yields of different types of​investments? The accompanying data provide yields for a​ one-year certificate of deposit​ (CD) and a​ five-year CD for 25 banks. Complete parts a through b below. Bank   One-Year CD   Five-Year CD 1   0.45   4.90 2   0.75   4.95 3   0.85   4.90 4   0.25   3.25 5   0.35   4.05 6   0.20   4.00 7   0.50   3.80 8   2.05   4.40 9   0.65   4.70 10   0.75   4.00 11   0.40   4.50 12   0.55   3.50 13   0.25   4.20...
17.18 LAB 8A: Input and formatted output: Left-facing arrow You will be working on generating a...
17.18 LAB 8A: Input and formatted output: Left-facing arrow You will be working on generating a formatted output using characters such as *, #, -, +. You need to prompt the user for a character for the arrowhead, and a character for the arrow body, and then print a left-facing arrow. Your prompts should be exactly "Enter a character for the arrowhead:" and "Enter a character for the arrow body:", as shown below. Ex: If the user inputs a *...
C++ Parse text (with delimiter) read from file. If a Text file has input formatted such...
C++ Parse text (with delimiter) read from file. If a Text file has input formatted such as: "name,23" on every line where a comma is the delimiter, how would I separate the string "name" and integer "23" and set them to separate variables for every input of the text file? I am trying to set a name and age to an object and insert it into a vector. #include <iostream> #include <vector> #include <fstream> using namespace std; class Student{    ...
Write a program to implement problem statement below: provide the menu for input N and number...
Write a program to implement problem statement below: provide the menu for input N and number of experiment M to calculate average time on M runs. randomly generated list. State your estimate on the BigO number of your algorithm/program logic. (we discussed in the class) Measure the performance of your program by given different N with randomly generated list with multiple experiment of Ns against time to draw the BigO graph (using excel) we discussed during the lecture. Lab-08-BigBiggerBiggtest.png ***...
Write a program that encrypts and decrypts the user input. Note – Your input should be...
Write a program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x) given by...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x)...
Objectives: Write a program which reads User Input using Scanner Print formatted output using printf or...
Objectives: Write a program which reads User Input using Scanner Print formatted output using printf or DecimalFormat Practice programming simple mathematical calculations Instructions: Samwise Gamgee has finally decided to submit his expense report for all of his adventures regarding his travels to Mordor. Part of those expenses are his stay at the Prancing Pony Inn located in Bree. You are to write a simple Java program which will generate an Invoice for his stay at the Inn. Your program should...
Rank in order of total heat input (Note: don’t confuse with heat input RATE) and overall...
Rank in order of total heat input (Note: don’t confuse with heat input RATE) and overall size of heat affected zone: GTAW, SMAW, Oxyfuel, laser beam welding What are the advantages of reducing total heat input in a weld?
Write a loop that reads positive integers from standard input, printing out those values that are...
Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, and that terminates when it reads an integerthat is not positive. The values should be separated by single blank spaces. Declare any variables that are needed. PLEASE ANSWER IN C
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT