I have a assignment, (well tones really) but the problem is, I don't understand C# no really, I have no idea how to request input from the user at what given time, I thought the transition from some aspects of c++ would be easy but unfortunately Its not, even the most basic things, i can use a converter but I'm totally unsure why c# giving me grief.
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
/*
Runs with out any hassles
*/
int main()
{
std::cout<<"Currency converter"<<std::endl;
// Declared variables
double Au = 0.8, Us = 1.0;
double output1, input1, input2, output2;
std::cout << "--------------------- "<<std::endl;
std::cout <<"Au to Us: $"<<std::flush;
cin >> input1;
output1 = Au / Us * input1;
output1 = Us / Au * input1;
std::cout << "--------------------- "<<std::endl;
std::cout <<"$1 Aud to Us is $"<<output1<<std::endl;
std::cout << "--------------------- "<<std::endl;
std::cout <<"Us to Au: $"<<std::flush;
cin >> input2;
output2 = Us / Au * input2;
output2 = Au / Us * input2;
std::cout << "--------------------- "<<std::endl;
std::cout << "$1 Us to Au is $"<<output2<<std::endl;
std::cout << "--------------------- "<<std::endl;
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
/*Please dont change namespace, Dcoder
and class must not be public*/
//Compiler version 4.0, .NET Framework 4.5
/*
Gives me grief and constant errors
*/
namespace Dcoder
{
publicclass Program
{
publicstaticvoid Main(string[] args)
{
std::cout<<<<std::endl;
Console.WriteLine("Currency converter");
// Declared variables
double Au = 0.8, Us = 1.0;
double output1, input1, input2, output2;
Console.WriteLine("--------------------- ")
Console.readLine(input1);
Console.log()"Au to Us: $");
output1 = Au / Us * input1;
output1 = Us / Au * input1;
Console.WriteLine("--------------------- ");
Console.WriteLine("$1 Aud to Us is $" + output1);
Console.WriteLine("--------------------- ");
Console.WriteLine(input2);
Console.WriteLine("Us to Au: $");
output2 = Us / Au * input2;
output2 = Au / Us * input2;
Console.WriteLine("--------------------- ");
Console.WriteLine("$1 Us to Au is $" + output2);
Console.WriteLine("--------------------- ");
Console.WriteLine("Us to Au: $");
Console.readkey();
}
}
}
////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
/*
No idea, was advised to use it
*/
/*Please dont change namespace, Dcoder
and class must not be public*/
//Compiler version 4.0, .NET Framework 4.5
namespace Dcoder
{
publicclass Program
{
publicstaticvoid Main(string[] args)
{
Console.Write("Currency converter");
Console.Write("\n");
// Declared variables
double Au = 0.8;
double Us = 1.0;
double output1;
double output2;
double input1;
double input2;
Console.Write("--------------------- ");
Console.Write("\n");
//Tangiable software converter C++ TO C# CONVERTER TODO TASK: The cout 'flush' manipulator is not converted by C++ to C# Converter:
//ORIGINAL LINE: std::cout <<"Au to Us: $"<<std::flush;
Console.Write("Au to Us: $");
double input1 = Console.ReadLine();
output1 = Au / Us * input1;
//output1 = Us / Au * input1;
Console.Write("--------------------- ");
Console.Write("\n");
Console.Write("$1 Aud to Us is $");
Console.Write(output1);
Console.Write("\n");
Console.Write("--------------------- ");
Console.Write("\n");
//C++ TO C# CONVERTER TODO TASK: The cout 'flush' manipulator is not converted by C++ to C# Converter:
//ORIGINAL LINE: std::cout <<"Us to Au: $"<<std::flush;
Console.Write("Us to Au: $");
double input2 = Console.ReadLine();
output2 = Us / Au * input2;
//output2 = Au / Us * input2;
Console.Write("--------------------- ");
Console.Write("\n");
Console.Write("$1 Us to Au is $");
Console.Write(output2);
Console.Write("\n");
Console.Write("--------------------- ");
Console.Write("\n");
}
}
}
using System;
/*
No idea, was advised to use it
*/
/*Please dont change namespace, Dcoder
and class must not be public*/
//Compiler version 4.0, .NET Framework 4.5
namespace Dcoder
{
publicclass Program
{
publicstaticvoid Main(string[] args)
{
Console.Write("Currency converter");
Console.Write("\n");
// Declared variables
double Au = 0.8;
double Us = 1.0;
double output1;
double output2;
double input1;
double input2;
Console.Write("--------------------- ");
Console.Write("\n");
//Tangiable software converter C++ TO C# CONVERTER TODO TASK: The cout 'flush' manipulator is not converted by C++ to C# Converter:
//ORIGINAL LINE: std::cout <<"Au to Us: $"<<std::flush;
Console.Write("Au to Us: $");
string buffer = Console.ReadLine();
input1 = Convert.ToDouble(buffer);
output1 = Au / Us * input1;
//output1 = Us / Au * input1;
Console.Write("--------------------- ");
Console.Write("\n");
Console.Write("$1 Aud to Us is $");
Console.Write(output1);
Console.Write("\n");
Console.Write("--------------------- ");
Console.Write("\n");
//C++ TO C# CONVERTER TODO TASK: The cout 'flush' manipulator is not converted by C++ to C# Converter:
//ORIGINAL LINE: std::cout <<"Us to Au: $"<<std::flush;
Console.Write("Us to Au: $");
buffer = Console.ReadLine();
input2 = Convert.ToDouble(buffer);
output2 = Us / Au * input2;
//output2 = Au / Us * input2;
Console.Write("--------------------- ");
Console.Write("\n");
Console.Write("$1 Us to Au is $");
Console.Write(output2);
Console.Write("\n");
Console.Write("--------------------- ");
Console.Write("\n");
}
}
}
source_file.cs(17,4): error CS0103: The name `Au' does not exist in the current context
source_file.cs(25,16): error CS0103: The name `Au' does not exist in the current context
source_file.cs(37,23): error CS0103: The name `Au' does not exist in the current context
string buffer = Console.ReadLine();
input1 = Convert.ToDouble(buffer);
output1 = Au / Us * input1
Personally I didn't think to approach it in this manner, (I still enjoy getting into the code, yes c# teaches you rules and I think that's good, I guess the teacher expected me to learn c# in one day before I wasn't sure how to convert a string to a international, especially with parse) anyways I would have used stod or stold, string over double but not sure in c++ 2011.
You passed in a buffer is it c# then continued on
buffer = Console.ReadLine();
input2 = Convert.ToDouble(buffer);
output2 = Us / Au * input2;
Ps, Au wasn't assigned to a double, I mean common it's not easy coding on a phone, the look the teacher gives me 😃
Here's some free hugs and cake.🎂🤗🤗🤗🤗🎂