I
I
Ivan Ivanov2014-01-26 20:30:35
C++ / C#
Ivan Ivanov, 2014-01-26 20:30:35

Getting rid of the exponential notation of the response and simplifying the code

There is code that asks the user for a dollar amount and then prints the dollar equivalent in other currencies.

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
  setlocale(0,"");
const float funt = 1.487F;
const float frank = 0.172F;
const float marka = 0.584F;
const float iena = 0.00955F;
float dollar;
  cout << "Введите кол-во долларов: ";
  cin >> dollar;
  cout << "фунт стерлингов" << setw(20) << std::setprecision(2) << dollar/funt
     << "\nфранц. франки" << setw(22) << std::setprecision(2) << dollar/frank
     << "\nнемецкая марка" << setw(21) << std::setprecision(2) << dollar/marka
     << "\nйена" << setw(31) << std::setprecision(2) << dollar/iena << endl;
system("pause");
}

Question:
1) Is it possible to somehow simplify it or have I done all the rules?
2) How to get rid of the exponent notation of the response. For example, it outputs x^e+0.008 , but I need an answer in the form of 0.008x (namely, the full answer like 0.194)?
t98jdz4pt8k0.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
egor_nullptr, 2014-01-26
@Csklassami

... << setw(20) << sprintf("%.3f", dollar/funt)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question