Question

USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number s...

USING C#

1. Write a program that takes outputs a string, an integer and a floating-point number separated by commas. Sample output: Bob Marley, 20, 5.2 2.

2. Write a program that asks the user for a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’). Generate a random number of any size, integer or floating point, and combine those three pieces of information (in any order) to create a password and display that out to the user. Sample input 1: ILikePatterns + Sample output 1: 525235325ILikePatterns+ Sample input 2: ILikeDecimalNumbers / Sample output 2: ILikeDecimalNumbers/52325.25

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

using System;

class MainClass {

public static void Main (string[] args) {

//Console.WriteLine ("Hello World");

String str;

int number;

float floatNumber;

Console.WriteLine("Enter a strting: ");

str=Console.ReadLine();

Console.WriteLine("Enter a number: ");

number=(int)Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter a float number: ");

floatNumber=(float)Convert.ToDouble(Console.ReadLine());

Console.WriteLine(""+str+","+number+","+floatNumber);

}

}

==============

//Output

Enter a strting:
Bob Marley
Enter a number:
20
Enter a float number:
5.2
Bob Marley,20,5.2

=========================

2.

using System;

class MainClass {

public static void Main (string[] args) {

Console.WriteLine (" Enter a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’): ");

string str="";

char c;

while(true)

{

c=(char) Console.Read();

if(c == 32) //if space don't take it

continue;

if(c>=33 && c<=47)

{

str+=c;

break;

}

str+=c;

}

Console.WriteLine ("\nString enetered is: "+str);

}

}

==========================

Enter a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’):
Hello WORLD!
String enetered is: HelloWORLD!

========================================

3.

using System;
public class Program {
public static void Main() {
Random rand = new Random();
int size= rand.Next(1,10);
Console.WriteLine("Enter a string: ");
string str=Console.ReadLine();
string str1="";
//generate integer number
for(int i = 0; i < size; i++)
str1+=rand.Next(0,10)+48;
string result=str+str1+"+";
  
Console.WriteLine(""+result);
}
}

=========================

//Output

Enter a string:                                                                                                                     

ILikeDecimalNumbers                                                                                                                 

ILikeDecimalNumbers48575149+

Add a comment
Know the answer?
Add Answer to:
USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number s...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT