Part 1: Python code; rewrite this code in C#, run the program and submit - include comments
number= 4
guesscount=0
guess=int(input("Guess a number between 1 and 10: "))
while guess!=number:
guesscount=guesscount+1
if guess<number:
print("Your guess is too low")
elif guess>number:
print("Your guess is too high")
else:
print("You got it!!")
guess=int(input("Guess again: "))
print("You figured it out in ",guesscount," guesses")
Part 2: C++ code; rewrite the following code in C#. Run the program and submit. - include comments
#include <iostream>
using namespace std;
int main()
{
int count=1, total=0;
while(count<=100)
{
total +=count;
count++;
}
cout<<"The sum of the numbers 1 - 100 is "<<total<<endl;
return 0;
}
So i have used youed you guys a lot and none of you have been able to answer any of my questions correctly. I need this code to be 100 percent right if you can not do it dont submit it back to me. I also need it IN DETAIL WHAT YOU DID IN A PARAGRAPH IF YOU CANT DO THIS DO NOT RETURN IT TO ME.
part 1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace myGame
{
public class Game
{
public static void Main(string[] args)
{
int number = 4;
int guesscount = 0;
Console.WriteLine("Guess a number between 1 and 10 : ");
// scan the number
int guess = Convert.ToInt32(Console.ReadLine());
// indefinite loop
while(true)
{
// increment the number of guesses
guesscount++;
// if guessed number is less than the ans
if(guess<number)
Console.WriteLine("Your guess is too low");
// if guessed number is more than the ans
else if(guess>number)
Console.WriteLine("Your guess is too high");
// if guessed number is correct
else
{
Console.WriteLine("You got it");
// break out of loop
break;
}
Console.WriteLine("Guess again");
// scan the number
guess = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("You figured it out in " + guesscount + " guesses");
}
}
}
Sample Output:

Part 2.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace mySolution
{
public class Solution
{
public static void Main(string[] args)
{
int count=1, total=0;
while(count <= 100)
{
total +=count;
count++;
}
Console.WriteLine("The sum of the numbers 1 - 100 is " + total);
}
}
}
Sample output:

Part 1: Python code; rewrite this code in C#, run the program and submit - include...
Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...
Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...
In python how could I update my code to tell me the number of guesses it took my to get the correct number here is my working code so far import random number = random.randint(1,100) total_guess = 0 while total_guess<=100: guess = int(input("what is your guess?")) print (guess) total_guess = total_guess + 1 if guess<number: print("Too low") if guess>number: print("Too high") if guess==number: print("Correct!") break
lab5 is to rewrite lab1 by oop
the code down below is the code of lab1
Lab 5 Rewrite the program in Lab 1 in object-oriented programming. You need to analyze the functionalities in Lab 1. You may define any number of classes if necessary. For example, you can consider in this way: one object for the game procedure, the other object for the player. In this way, you should define a protocol so that the game object has minimal...
Can someone help me make the output of this code more spaced out? #include<iostream> #include<cstdlib> using namespace std; int main() { int amount=1000,guess,answer,bet,count=0,win=0; float per; char ch; cout<<"Welcome to the high-low betting game.\nYou have $1000 to begin the game.\nValid guesses are numbers between 1 and 100.\n"; do { cout<<"Please enter a bet:\n"; cin>>bet; answer=rand()%100; for (int i=0;i<6;i++) { cout<<"Guess "<<i+1<<":"; ...
Can someone please rewrite this code using a while loop? Please write it in python. #The winning number my_number = 12 #variable for the input name user_n = input("Hello! What is your name?") #Ask the user print("Well",user_n,": I am thinking of a number between 1 and 20." + "Take a guess.") user_n = float(input("Take a guess.")) #if statements if user_n == my_number: print("Good job" ,user_n, "You guessed my number!") if user_n > my_number: print("Your guess is high. You lose.") if...
This is the source code: Please incorporate the Exception
Handling
import javax.swing.JOptionPane;
import java.awt.*;
public class GuessingGame {
public static void main(String[] args) {
int computerNumber = (int) (Math.random() * 10 + 1);
System.out.println("The correct guess would be " +
computerNumber);
int userAnswer = 0;
int count = 0;
while (computerNumber != userAnswer) {
count++;
String response = JOptionPane.showInputDialog(null,
"Enter a guess between 1 and 10");
userAnswer = Integer.parseInt(response);
String result = null;
if (userAnswer == computerNumber) {
result =...
Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...
Python 3 Can anyone make my Python code more readable, by breaking up the code into smaller chunks using functions. If a piece of code tries to do several things, it should be broken up into several different functions. print("chatbot: Hello, I am chatbot. What is your name?") name = input("") print("chatbot: Nice to meet you "+name+". Tell me now, what is your age?") age = int(input("")) if age >= 16 and age <= 25: print("We are the same age!...
1.
program to use with number 1.
2.
Comparing Python and Java Discussion Forum 14 days ago Use the Python IDLE editor to create the source code for the "numberguess.py" pro- gram. This program is in the "Basic Python Pro- gramming" chapter in its "An Example Python Program: Guessing a Number" section. If you mistakenly create syntax errors, find and fix them. Run the program and test it with various values. Refer to the "numberguess.py Program document to see example...