Question

In: Computer Science

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

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

Solutions

Expert Solution

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+


Related Solutions

C++ Write a program that takes a string and integer as input, and outputs a sentence...
C++ Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is "quit". If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps your doctor away. Eating 2 shoes a day keeps your doctor away.
Write a program that takes in a positive integer as input, and outputs a string of...
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x / 2 Note: The above algorithm outputs the 0's and 1's in reverse order. Ex: If the input is: 6 the output is: 011 6 in binary is...
[C] Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
6.19 LAB: Convert to binary - functionsWrite a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string.Ex: If the input is:6the output is:110Your program must define and call the following two functions. The IntegerToReverseBinary function...
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
USE Coral Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is 6, the output is:011(6 in binary is 110; the algorithm outputs the bits in reverse).
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
In Java  Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is:6the output is:0116 in binary is 110; the algorithm outputs the bits in reverse.
(Python) Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
In Python8.21 Program: Convert to binary. Sections 2.7, 3.8, 5.2. Functions.Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x // 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string.Your program must define and call the following two functions. The function integer_to_reverse_binary() should return...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string....
a program that takes an integer and outputs the resulting factorial number.
assembly x86 language program a program that takes an integer and outputs the resulting factorial number. 
rogram that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary.
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x // 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string.Ex: If the input is:6the output is:110Your program must define and call the following two functions. The function integer_to_reverse_binary() should return a string of 1's...
In c++ Write a program that reads a string consisting of a positive integer or a...
In c++ Write a program that reads a string consisting of a positive integer or a positive decimal number and converts the number to the numeric format. If the string consists of a decimal number, the program must use a stack to convert the decimal number to the numeric format. Use the STL stack
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT